Skip to content

Commit 73a0593

Browse files
author
Evgeny Poberezkin
authored
Merge pull request #169 from epoberezkin/draft6-tests-ajv
test: run draft-04/06 tests with ajv
2 parents 8758156 + e2e06d7 commit 73a0593

File tree

4 files changed

+68
-4
lines changed

4 files changed

+68
-4
lines changed

.travis.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
language: python
22
python: "2.7"
3-
install: pip install tox
4-
script: tox
3+
node_js: "6"
4+
install:
5+
- pip install tox
6+
- npm install
7+
script:
8+
- tox
9+
- npm test

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
JSON Schema Test Suite [![Build Status](https://travis-ci.org/json-schema-org/JSON-Schema-Test-Suite.png?branch=develop)](https://travis-ci.org/json-schema-org/JSON-Schema-Test-Suite)
1+
JSON Schema Test Suite [![Build Status](https://travis-ci.org/json-schema-org/JSON-Schema-Test-Suite.svg?branch=master)](https://travis-ci.org/json-schema-org/JSON-Schema-Test-Suite)
22
======================
33

44
This repository contains a set of JSON objects that implementors of JSON Schema
@@ -165,5 +165,5 @@ Contributing
165165
If you see something missing or incorrect, a pull request is most welcome!
166166

167167
There are some sanity checks in place for testing the test suite. You can run
168-
them with `bin/jsonschema_suite check` or `tox`. They will be run automatically by
168+
them with `bin/jsonschema_suite check && npm test` or `tox && npm test`. They will be run automatically by
169169
[Travis CI](https://travis-ci.org/) as well.

index.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
'use strict';
2+
3+
var Ajv = require('ajv');
4+
var jsonSchemaTest = require('json-schema-test');
5+
var assert = require('assert');
6+
7+
var refs = {
8+
'http://localhost:1234/integer.json': require('./remotes/integer.json'),
9+
'http://localhost:1234/subSchemas.json': require('./remotes/subSchemas.json'),
10+
'http://localhost:1234/folder/folderInteger.json': require('./remotes/folder/folderInteger.json')
11+
};
12+
13+
runTest(4);
14+
runTest(6);
15+
16+
function runTest(draft) {
17+
var opts = {addUsedSchema: false};
18+
if (draft == 4) opts.meta = false;
19+
var ajv = new Ajv(opts);
20+
ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json'));
21+
if (draft == 4) ajv._opts.defaultMeta = 'http://json-schema.org/draft-04/schema#';
22+
for (var uri in refs) ajv.addSchema(refs[uri], uri);
23+
24+
jsonSchemaTest(ajv, {
25+
description: 'Test suite draft-0' + draft,
26+
suites: {tests: './tests/draft' + draft + '/{**/,}*.json'},
27+
skip: draft == 4 ? ['optional/zeroTerminatedFloats'] : [],
28+
cwd: __dirname,
29+
hideFolder: 'tests/'
30+
});
31+
}

package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "json-schema-test-suite",
3+
"version": "0.1.0",
4+
"description": "A language agnostic test suite for the JSON Schema specifications",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "mocha index.js -R spec"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/json-schema-org/JSON-Schema-Test-Suite.git"
12+
},
13+
"keywords": [
14+
"json-schema",
15+
"tests"
16+
],
17+
"author": "http://json-schema.org",
18+
"license": "MIT",
19+
"bugs": {
20+
"url": "https://github.com/json-schema-org/JSON-Schema-Test-Suite/issues"
21+
},
22+
"homepage": "https://github.com/json-schema-org/JSON-Schema-Test-Suite#readme",
23+
"devDependencies": {
24+
"ajv": "^5.0.4-beta.0",
25+
"json-schema-test": "^1.3.0",
26+
"mocha": "^3.2.0"
27+
}
28+
}

0 commit comments

Comments
 (0)