Skip to content

Commit

Permalink
tests for custom keywords, remove constant (alias of const)
Browse files Browse the repository at this point in the history
  • Loading branch information
epoberezkin committed Jan 7, 2018
1 parent 23f7e94 commit a42e37b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "spec/JSON-Schema-Test-Suite"]
path = spec/JSON-Schema-Test-Suite
url = https://github.com/json-schema/JSON-Schema-Test-Suite.git
[submodule "spec/ajv-keywords"]
path = spec/ajv-keywords
url = https://github.com/epoberezkin/ajv-keywords.git
15 changes: 0 additions & 15 deletions messages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -597,21 +597,6 @@ module.exports = {
sv: 'bör vara en konstant',
zh: '应当等于常量'
},
constant: {
en: 'should be equal to constant',
ar: 'يجب أن يكون غير ثاباً',
cz: 'musí být konstantní',
de: 'sollte der Konstante entsprechen',
es: 'debe ser igual a la constante',
fr: 'doit être égal à la constante',
nb: 'må være lik konstanten',
pl: 'powinien być równy stałej',
'pt-BR': 'deve ser igual à constante',
ru: 'должно быть равно заданному значению',
sk: 'musí byť konštanta',
sv: 'bör vara en konstant',
zh: '应当等于常量'
},
contains: {
en: 'should contain a valid item',
ar: 'يجب أن يحوي عنصرا صحيح',
Expand Down
1 change: 1 addition & 0 deletions spec/ajv-keywords
Submodule ajv-keywords added at ea618a
14 changes: 9 additions & 5 deletions spec/localize.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ var remoteRefs = {

var SKIP = {
'draft-04': ['optional/zeroTerminatedFloats'],
'draft-06': [],
'draft-07': [
'format/idn-email',
'format/idn-hostname',
Expand All @@ -26,6 +25,11 @@ var SKIP = {
]
};

var DEFAULT_META = {
'draft-04': 'http://json-schema.org/draft-04/schema#',
'draft-06': 'http://json-schema.org/draft-06/schema#'
};

var suites = testSuites();
for (var s in suites) runTests(s);

Expand All @@ -39,8 +43,8 @@ function runTests(suite) {

instances.forEach(function (ajv) {
addRemoteRefs(ajv);
if (suite != 'draft-07')
ajv._opts.defaultMeta = 'http://json-schema.org/' + suite + '/schema#';
if (DEFAULT_META[suite])
ajv._opts.defaultMeta = DEFAULT_META[suite];
});

var tests = {};
Expand Down Expand Up @@ -72,7 +76,6 @@ function getAjv(allErrors, verbose) {
ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json'));
ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-06.json'));
ajvKeywords(ajv, ['switch', 'patternRequired', 'formatMinimum', 'formatMaximum']);
ajv.addKeyword('constant', { macro: function(x) { return { const: x }; } });
return ajv;
}

Expand All @@ -96,7 +99,8 @@ function testSuites() {
_suites = {
'draft-04': './JSON-Schema-Test-Suite/tests/draft4/{**/,}*.json',
'draft-06': './JSON-Schema-Test-Suite/tests/draft6/{**/,}*.json',
'draft-07': './JSON-Schema-Test-Suite/tests/draft7/{**/,}*.json'
'draft-07': './JSON-Schema-Test-Suite/tests/draft7/{**/,}*.json',
'ajv-keywords': './ajv-keywords/spec/tests/{format*,patternRequired,switch}.json'
};
}
return _suites;
Expand Down

0 comments on commit a42e37b

Please sign in to comment.