forked from ajv-validator/ajv-i18n
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstyle.spec.js
42 lines (32 loc) · 1.18 KB
/
style.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'use strict';
var messages = require('../messages');
var localize = require('../localize');
var assert = require('assert');
describe('code style: ordering of locales', function() {
it('locales in index.js should be ordered (en first)', function() {
testLocalesProperties(localize);
});
it('_locales should be ordered (en first)', function () {
testLocalesOrder(messages._locales);
});
it('locales in _defs should be ordered (en first)', function () {
testLocalesProperties(messages._defs.mPlural, '_defs.mPlural');
testLocalesProperties(messages._defs.propPlural, '_defs.propPlural');
});
it('locales in keywords should be ordered (en first)', function() {
for (var keyword in messages) {
if (keyword[0] == '_') continue;
testLocalesProperties(messages[keyword], 'keyword ' + keyword);
}
});
});
function testLocalesOrder(locales, message) {
assert.equal(locales[0], 'en', message);
var ordered = ['en'].concat(locales.slice(1).sort());
assert.deepEqual(locales, ordered, message);
}
function testLocalesProperties(obj, message) {
var props = Object.keys(obj);
if (props[0][0] == '_') props.shift();
testLocalesOrder(props, message);
}