-
-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathBooleanSchema.test.js
More file actions
52 lines (44 loc) · 1.22 KB
/
BooleanSchema.test.js
File metadata and controls
52 lines (44 loc) · 1.22 KB
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
'use strict'
const { describe, it } = require('node:test')
const assert = require('node:assert/strict')
const { BooleanSchema } = require('./BooleanSchema')
const S = require('./FluentJSONSchema')
describe('BooleanSchema', () => {
it('defined', () => {
assert.notStrictEqual(BooleanSchema, undefined)
})
it('Expose symbol', () => {
assert.notStrictEqual(
BooleanSchema()[Symbol.for('fluent-schema-object')],
undefined
)
})
describe('constructor', () => {
it('without params', () => {
assert.deepStrictEqual(BooleanSchema().valueOf(), {
type: 'boolean'
})
})
it('from S', () => {
assert.deepStrictEqual(S.boolean().valueOf(), {
$schema: 'http://json-schema.org/draft-07/schema#',
type: 'boolean'
})
})
})
it('sets a null type to the prop', () => {
assert.strictEqual(
S.object().prop('prop', S.boolean()).valueOf().properties.prop.type,
'boolean'
)
})
describe('raw', () => {
it('allows to add a custom attribute', () => {
const schema = BooleanSchema().raw({ customKeyword: true }).valueOf()
assert.deepStrictEqual(schema, {
type: 'boolean',
customKeyword: true
})
})
})
})