Skip to content

Commit

Permalink
test: test the json schema
Browse files Browse the repository at this point in the history
  • Loading branch information
barmac committed Feb 26, 2024
1 parent 785784c commit eafe3c5
Show file tree
Hide file tree
Showing 4 changed files with 216 additions and 18 deletions.
4 changes: 2 additions & 2 deletions docs/moddle.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"required": [
"name",
"prefix",
Expand All @@ -14,8 +15,7 @@
"type": "array",
"items": {
"required": [
"name",
"properties"
"name"
],
"properties": {
"name": {
Expand Down
198 changes: 182 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@
"@rollup/plugin-commonjs": "^24.0.1",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-terser": "^0.4.0",
"ajv": "^8.12.0",
"chai": "^4.3.7",
"eslint": "^8.34.0",
"eslint-plugin-bpmn-io": "^1.0.0",
"fast-glob": "^3.3.2",
"mocha": "^10.2.0",
"npm-run-all": "^4.1.2",
"rollup": "^3.17.2"
Expand Down
30 changes: 30 additions & 0 deletions test/spec/schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Ajv from 'ajv';
import FastGlob from 'fast-glob';

import { readFile } from '../helper.js';
import expect from '../expect.js';


describe('JSON schema', () => {

let validator;

before(() => {
const schema = readFile('docs/moddle.json');

validator = new Ajv().compile(JSON.parse(schema));
});


for (const file of FastGlob.globSync('test/fixtures/model/**/*.json')) {

it(`should validate fixture: ${file}`, () => {

// given
const model = JSON.parse(readFile(file));

// then
expect(validator(model)).to.be.true;
});
}
});

0 comments on commit eafe3c5

Please sign in to comment.