aboutsummaryrefslogtreecommitdiff
path: root/test/test-schema.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/test-schema.js')
-rw-r--r--test/test-schema.js86
1 files changed, 86 insertions, 0 deletions
diff --git a/test/test-schema.js b/test/test-schema.js
index 34dd857a..0141f1ce 100644
--- a/test/test-schema.js
+++ b/test/test-schema.js
@@ -358,6 +358,19 @@ function testValidate2() {
{expected: false, value: 1}
]
},
+ {
+ schema: {
+ type: 'integer',
+ multipleOf: 2
+ },
+ inputs: [
+ {expected: true, value: -2},
+ {expected: false, value: -1},
+ {expected: true, value: 0},
+ {expected: false, value: 1},
+ {expected: true, value: 2}
+ ]
+ },
// Numeric type tests
{
@@ -595,6 +608,79 @@ function testGetValidValueOrDefault1() {
{toString: 'default'}
]
]
+ },
+
+ // Test enum
+ {
+ schema: {
+ type: 'object',
+ required: ['test'],
+ properties: {
+ test: {
+ type: 'string',
+ default: 'value1',
+ enum: ['value1', 'value2', 'value3']
+ }
+ }
+ },
+ inputs: [
+ [
+ {test: 'value1'},
+ {test: 'value1'}
+ ],
+ [
+ {test: 'value2'},
+ {test: 'value2'}
+ ],
+ [
+ {test: 'value3'},
+ {test: 'value3'}
+ ],
+ [
+ {test: 'value4'},
+ {test: 'value1'}
+ ]
+ ]
+ },
+
+ // Test valid vs invalid default
+ {
+ schema: {
+ type: 'object',
+ required: ['test'],
+ properties: {
+ test: {
+ type: 'integer',
+ default: 2,
+ minimum: 1
+ }
+ }
+ },
+ inputs: [
+ [
+ {test: -1},
+ {test: 2}
+ ]
+ ]
+ },
+ {
+ schema: {
+ type: 'object',
+ required: ['test'],
+ properties: {
+ test: {
+ type: 'integer',
+ default: 1,
+ minimum: 2
+ }
+ }
+ },
+ inputs: [
+ [
+ {test: -1},
+ {test: -1}
+ ]
+ ]
}
];