-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Hasan Eroglu <[email protected]>
- Loading branch information
1 parent
8fac263
commit eb39f70
Showing
5 changed files
with
80 additions
and
0 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
8 changes: 8 additions & 0 deletions
8
things/advanced-coffee-machine/advanced-coffee-machine.tm.json
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,32 @@ | ||
const Ajv = require('ajv') | ||
const chai = require('chai') | ||
const https = require('https') | ||
|
||
const ajv = new Ajv({ strict: false, allErrors: true, validateFormats: false }) | ||
|
||
const expect = chai.expect | ||
|
||
describe('Advanced Coffee Machine', () => { | ||
let validate | ||
|
||
before((done) => { | ||
https.get('https://raw.githubusercontent.com/w3c/wot-thing-description/main/validation/tm-json-schema-validation.json', function (response) { | ||
const body = [] | ||
response.on('data', (chunk) => { | ||
body.push(chunk) | ||
}) | ||
|
||
response.on('end', () => { | ||
const tmSchema = JSON.parse(Buffer.concat(body).toString()) | ||
validate = ajv.compile(tmSchema) | ||
done() | ||
}) | ||
}) | ||
}) | ||
|
||
it('should have a valid TM', () => { | ||
const advancedCoffeeMachineTM = require('./advanced-coffee-machine.tm.json') | ||
const valid = validate(advancedCoffeeMachineTM) | ||
expect(valid).to.be.true | ||
}) | ||
}) |
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,32 @@ | ||
const Ajv = require('ajv') | ||
const chai = require('chai') | ||
const https = require('https') | ||
|
||
const ajv = new Ajv({ strict: false, allErrors: true, validateFormats: false }) | ||
|
||
const expect = chai.expect | ||
|
||
describe('Test Thing', () => { | ||
let validate | ||
|
||
before((done) => { | ||
https.get('https://raw.githubusercontent.com/w3c/wot-thing-description/main/validation/tm-json-schema-validation.json', function (response) { | ||
const body = [] | ||
response.on('data', (chunk) => { | ||
body.push(chunk) | ||
}) | ||
|
||
response.on('end', () => { | ||
const tmSchema = JSON.parse(Buffer.concat(body).toString()) | ||
validate = ajv.compile(tmSchema) | ||
done() | ||
}) | ||
}) | ||
}) | ||
|
||
it('should have a valid TM', () => { | ||
const testThingTM = require('./test-thing.tm.json') | ||
const valid = validate(testThingTM) | ||
expect(valid).to.be.true | ||
}) | ||
}) |