-
Notifications
You must be signed in to change notification settings - Fork 2
/
test-object-default-properties.js
67 lines (58 loc) · 1.48 KB
/
test-object-default-properties.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
'use strict';
/* global suite: false, setup: false, test: false,
teardown: false, suiteSetup: false, suiteTeardown: false */
var assert = require('assert');
var Registry = require('../');
suite('object-default-properties', function() {
var registry = new Registry();
test('defaults', function() {
registry.addSchema({
id: 'restful_acns',
type: 'object',
properties: {
visibilityTimeout: {
type: 'number',
min: 0,
max: 43200,
default: 30
},
maximumMessageSize: {
type: 'number',
min: 1024,
max: 65536,
default: 65536
},
messageRetentionPeriod: {
type: 'number',
min: 60,
max: 1209600,
default: 345600
},
delay: {
type: 'number',
min: 0,
max: 900,
default: 0
}
}
});
var data = {};
var errors = registry.test('restful_acns', data);
assert(!errors);
assert.strictEqual(30, data.visibilityTimeout);
assert.strictEqual(65536, data.maximumMessageSize);
assert.strictEqual(345600, data.messageRetentionPeriod);
assert.strictEqual(0, data.delay);
});
test('allowNullValue', function() {
registry.addSchema({
id: 'foobar',
type: 'object',
allowUnknownProperties: true,
min: 2,
allowNullValue: true
});
var errors = registry.test('foobar', null);
assert(!errors);
});
});