mirror of
https://github.com/scratchfoundation/scratch-parser.git
synced 2025-08-12 06:08:55 -04:00
Initial functioning parser
This commit is contained in:
parent
4642c66e08
commit
a0a03ef679
36 changed files with 113034 additions and 102 deletions
test/unit
31
test/unit/validate.js
Normal file
31
test/unit/validate.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
var test = require('tap').test;
|
||||
var data = require('../fixtures/data');
|
||||
var validate = require('../../lib/validate');
|
||||
|
||||
test('spec', function (t) {
|
||||
t.type(validate, 'function');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('valid', function (t) {
|
||||
validate(JSON.parse(data.example.json), function (err, res) {
|
||||
t.equal(err, null);
|
||||
t.type(res, 'object');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('invalid', function (t) {
|
||||
validate({foo:1}, function (err, res) {
|
||||
t.equal(Array.isArray(err), true);
|
||||
t.equal(res, undefined);
|
||||
t.type(err[0], 'object');
|
||||
t.type(err[0].keyword, 'string');
|
||||
t.type(err[0].dataPath, 'string');
|
||||
t.type(err[0].schemaPath, 'string');
|
||||
t.type(err[0].message, 'string');
|
||||
t.type(err[0].params, 'object');
|
||||
t.type(err[0].params.missingProperty, 'string');
|
||||
t.end();
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue