-
Notifications
You must be signed in to change notification settings - Fork 2
/
test-primitive.js
46 lines (37 loc) · 1000 Bytes
/
test-primitive.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
'use strict';
/* global suite: false, setup: false, test: false,
teardown: false, suiteSetup: false, suiteTeardown: false */
var assert = require('assert');
var Registry = require('../');
suite('primitive', function() {
var registry = new Registry();
test('add "primitive" schema', function() {
registry.addSchema({
id: 'primitive',
type: 'object',
properties: {
flag: true,
text: 'abc',
v0id: null,
uint: 123
}
});
});
test('validate "primitive"', function() {
var errors = registry.test('primitive', {
v0id: 1,
flag: false,
text: 'abc',
uint: 123
});
assert.deepEqual(errors, [
['flag', 'boolean', 'value', false],
['v0id', 'null', 'type', 1]
]);
});
test('remove "primitive" schema', function() {
assert.deepEqual(registry.getSchemas(), ['primitive']);
registry.removeSchema('primitive');
assert.deepEqual([], registry.getSchemas());
});
});