-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Check for non-existent obsoletedBy values * Increment version number
- Loading branch information
1 parent
b33a8d5
commit e1795fb
Showing
9 changed files
with
1,241 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,5 @@ jobs: | |
with: | ||
node-version: '10' | ||
- run: npm install | ||
- run: npm test | ||
- run: npm run validate |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
const { loadValidators } = require("..") | ||
const chai = require('chai') | ||
const should = chai.should(); | ||
const assert = chai.assert | ||
|
||
describe("facilities schema", () => { | ||
let validate | ||
before(async () => { ({ facilities: { validate } } = await loadValidators() ) }) | ||
|
||
it("schema exists", () => { | ||
validate.should.be.a('function') | ||
}) | ||
|
||
it("correct validation", () => { | ||
assert.doesNotThrow(() => validate([ | ||
{ code: "AAA", description: "A A A" }, | ||
{ code: "BBB", description: "B B B", obsolete: true }, | ||
{ code: "CCC", description: "C C C", obsolete: true, comments: [ "foo", "bar" ] }, | ||
{ code: "DDD", description: "D D D", obsolete: true, comments: [ "foo", "bar" ], obsoletedBy: [ 'AAA', 'BBB' ] } | ||
])) | ||
}) | ||
|
||
it("bad order", () => { | ||
assert.throw(() => validate([ | ||
{ code: "BBB", description: "B B B", obsolete: true }, | ||
{ code: "AAA", description: "A A A" }, | ||
]), /sorted/) | ||
}) | ||
|
||
it("incorrect obsoletedBy", () => { | ||
assert.throw(() => validate([ | ||
{ code: "DDD", description: "C C C", obsolete: true, obsoletedBy: [ true ] } | ||
]), /fails schema/) | ||
}) | ||
|
||
it("obsoletedBy unknown code", () => { | ||
assert.throw(() => validate([ | ||
{ code: "AAA", description: "A A A" }, | ||
{ code: "DDD", description: "C C C", obsolete: true, obsoletedBy: [ "XYZ" ] } | ||
]), /invalid code/) | ||
}) | ||
|
||
it("empty obsoletedBy", () => { | ||
assert.throw(() => validate([ | ||
{ code: "DDD", description: "C C C", obsolete: true, obsoletedBy: [ ] } | ||
]), /fails schema/) | ||
}) | ||
|
||
it("incorrect obsolete", () => { | ||
assert.throw(() => validate([ | ||
{ code: "DDD", description: "C C C", obsolete: "foo", obsoletedBy: [ "AAA" ] } | ||
]), /fails schema/) | ||
}) | ||
|
||
it("no obsoletedBy without obsolete", () => { | ||
assert.throw(() => validate([ | ||
{ code: "DDD", description: "C C C", obsolete: false, obsoletedBy: [ "AAA" ] } | ||
]), /fails schema/) | ||
}) | ||
|
||
it("no obsoletedBy without obsoletedBy (implicit value)", () => { | ||
assert.throw(() => validate([ | ||
{ code: "DDD", description: "C C C", obsoletedBy: [ "AAA" ] } | ||
]), /fails schema/) | ||
}) | ||
|
||
it("invalid case", () => { | ||
assert.throw(() => validate([ | ||
{ code: "aaa", description: "A A A" }, | ||
{ code: "BBB", description: "B B B" } | ||
]), /fails schema/) | ||
}) | ||
|
||
it("additional", () => { | ||
assert.throw(() => validate([ | ||
{ code: "aaa", description: "A A A" }, | ||
{ code: "BBB", description: "B B B", foo: "bar" } | ||
]), /fails schema/) | ||
}) | ||
|
||
it("additional", () => { | ||
assert.throw(() => validate([ | ||
{ code: "DDD", description: "C C C", obsolete: true, comments: [ "foo", "bar" ], obsoletedBy: [ 'AAA', 'DDD' ], foo: "bar" } | ||
]), /fails schema/) | ||
}) | ||
|
||
it("code too long", () => { | ||
assert.throw(() => validate([ | ||
{ code: "AAA", description: "A A A" }, | ||
{ code: "BBBBB", description: "B B B" } | ||
]), /fails schema/) | ||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const { loadValidators } = require("..") | ||
const chai = require('chai') | ||
const should = chai.should(); | ||
const assert = chai.assert | ||
|
||
describe("languages schema", () => { | ||
before(async () => { ({ languages: { validate } } = await loadValidators() ) }) | ||
|
||
it("valid", () => { | ||
assert.doesNotThrow(() => validate([ | ||
{ | ||
"dcncTag": "SQ", | ||
"rfc5646Tag": "sq", | ||
"use": [ | ||
"audio", | ||
"text" | ||
], | ||
"comments": [ | ||
"DCNC notes: Albanian" | ||
] | ||
}, | ||
{ | ||
"dcncTag": "AR", | ||
"rfc5646Tag": "ar", | ||
"use": [ | ||
"audio", | ||
"text" | ||
], | ||
"comments": [ | ||
"DCNC notes: Arabic" | ||
] | ||
}])) | ||
}) | ||
|
||
it("invalid", () => { | ||
assert.throw(() => validate([ | ||
"foo" | ||
]), /fails schema/) | ||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
const { loadValidators } = require("..") | ||
const chai = require('chai') | ||
const should = chai.should(); | ||
const assert = chai.assert | ||
|
||
describe("studios schema", () => { | ||
let validate | ||
before(async () => { ({ studios: { validate } } = await loadValidators() ) }) | ||
|
||
it("schema exists", () => { | ||
validate.should.be.a('function') | ||
}) | ||
|
||
it("correct validation", () => { | ||
assert.doesNotThrow(() => validate([ | ||
{ code: "AAA", description: "A A A" }, | ||
{ code: "BBB", description: "B B B", obsolete: true }, | ||
{ code: "CCC", description: "C C C", obsolete: true, comments: [ "foo", "bar" ] }, | ||
{ code: "DDD", description: "D D D", obsolete: true, comments: [ "foo", "bar" ], obsoletedBy: [ 'AAA', 'BBB' ] } | ||
])) | ||
}) | ||
|
||
it("bad order", () => { | ||
assert.throw(() => validate([ | ||
{ code: "BBB", description: "B B B", obsolete: true }, | ||
{ code: "AAA", description: "A A A" }, | ||
]), /sorted/) | ||
}) | ||
|
||
it("incorrect obsoletedBy", () => { | ||
assert.throw(() => validate([ | ||
{ code: "DDD", description: "C C C", obsolete: true, obsoletedBy: [ true ] } | ||
]), /fails schema/) | ||
}) | ||
|
||
it("obsoletedBy unknown code", () => { | ||
assert.throw(() => validate([ | ||
{ code: "AAA", description: "A A A" }, | ||
{ code: "DDD", description: "C C C", obsolete: true, obsoletedBy: [ "XYZ" ] } | ||
]), /invalid code/) | ||
}) | ||
|
||
it("empty obsoletedBy", () => { | ||
assert.throw(() => validate([ | ||
{ code: "DDD", description: "C C C", obsolete: true, obsoletedBy: [ ] } | ||
]), /fails schema/) | ||
}) | ||
|
||
it("incorrect obsolete", () => { | ||
assert.throw(() => validate([ | ||
{ code: "DDD", description: "C C C", obsolete: "foo", obsoletedBy: [ "AAA" ] } | ||
]), /fails schema/) | ||
}) | ||
|
||
it("no obsoletedBy without obsolete", () => { | ||
assert.throw(() => validate([ | ||
{ code: "DDD", description: "C C C", obsolete: false, obsoletedBy: [ "AAA" ] } | ||
]), /fails schema/) | ||
}) | ||
|
||
it("no obsoletedBy without obsoletedBy (implicit value)", () => { | ||
assert.throw(() => validate([ | ||
{ code: "DDD", description: "C C C", obsoletedBy: [ "AAA" ] } | ||
]), /fails schema/) | ||
}) | ||
|
||
it("invalid case", () => { | ||
assert.throw(() => validate([ | ||
{ code: "aaa", description: "A A A" }, | ||
{ code: "BBB", description: "B B B" } | ||
]), /fails schema/) | ||
}) | ||
|
||
it("additional", () => { | ||
assert.throw(() => validate([ | ||
{ code: "aaa", description: "A A A" }, | ||
{ code: "BBB", description: "B B B", foo: "bar" } | ||
]), /fails schema/) | ||
}) | ||
|
||
it("additional", () => { | ||
assert.throw(() => validate([ | ||
{ code: "DDD", description: "C C C", obsolete: true, comments: [ "foo", "bar" ], obsoletedBy: [ 'AAA', 'DDD' ], foo: "bar" } | ||
]), /fails schema/) | ||
}) | ||
|
||
it("code too long", () => { | ||
assert.throw(() => validate([ | ||
{ code: "AAA", description: "A A A" }, | ||
{ code: "BBBBB", description: "B B B" } | ||
]), /fails schema/) | ||
}) | ||
|
||
}) |