Skip to content

Commit c6d5a0c

Browse files
committed
tests: Verify that collection example is valid
1 parent 8840efa commit c6d5a0c

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

tests/collection.test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const {join} = require('path');
2+
const {promises} = require('fs');
3+
const {AjvOptions, rootDirectory, schemaPath} = require('./validation.js');
4+
const ajv = new (require('ajv'))(AjvOptions);
5+
6+
const examplePath = join(rootDirectory, 'examples/collection.json');
7+
8+
let validate;
9+
beforeAll(async () => {
10+
const data = JSON.parse(await promises.readFile(schemaPath));
11+
validate = await ajv.compileAsync(data);
12+
});
13+
14+
let example;
15+
beforeEach(async () => {
16+
example = JSON.parse(await promises.readFile(examplePath));
17+
});
18+
19+
describe('Collection example', () => {
20+
it('should pass validation', async () => {
21+
let valid = validate(example);
22+
23+
expect(valid).toBeTruthy();
24+
});
25+
});

0 commit comments

Comments
 (0)