shinkansen-transmission 2.1.15 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.husky/pre-commit +4 -0
- package/babel.config.js +1 -1
- package/index.js +6 -1
- package/lib/index.js +1 -1
- package/lib/transmission/common/index.js +1 -1
- package/lib/transmission/from-document-to-hash/index.js +1 -1
- package/lib/transmission/from-hash-to-document/index.js +1 -1
- package/lib/transmission/index.js +1 -1
- package/lib/transmission/to-zashiki/index.js +1 -1
- package/lib/transmission/to-zashiki/transform-root-schema.js +1 -1
- package/lib/transmission/to-zashiki/transform-schema.js +1 -1
- package/package.json +23 -30
- package/src/transmission/from-document-to-hash/index.js +75 -29
- package/src/transmission/from-hash-to-document/index.js +13 -10
- package/src/transmission/to-zashiki/transform-root-schema.js +143 -136
- package/src/transmission/to-zashiki/transform-schema.js +3256 -1952
- package/.github/dependabot.yml +0 -9
- package/test/transmission/common/index.spec.js +0 -1348
- package/test/transmission/from-document-to-hash/index.spec.js +0 -1866
- package/test/transmission/from-hash-to-document/index.spec.js +0 -1523
- package/test/transmission/to-zashiki/transform-root-schema/transforming-array-type-schemas.spec.js +0 -1784
- package/test/transmission/to-zashiki/transform-root-schema/transforming-boolean-type-schemas.spec.js +0 -334
- package/test/transmission/to-zashiki/transform-root-schema/transforming-null-type-schemas.spec.js +0 -253
- package/test/transmission/to-zashiki/transform-root-schema/transforming-number-type-schemas.spec.js +0 -565
- package/test/transmission/to-zashiki/transform-root-schema/transforming-object-type-schemas.spec.js +0 -1715
- package/test/transmission/to-zashiki/transform-root-schema/transforming-string-type-schemas.spec.js +0 -496
- package/test/transmission/to-zashiki/transform-root-schema/with-values/with-params/transforming-array-type-schemas.spec.js +0 -31633
- package/test/transmission/to-zashiki/transform-root-schema/with-values/with-params/transforming-boolean-type-schemas.spec.js +0 -359
- package/test/transmission/to-zashiki/transform-root-schema/with-values/with-params/transforming-null-type-schemas.spec.js +0 -359
- package/test/transmission/to-zashiki/transform-root-schema/with-values/with-params/transforming-number-type-schemas.spec.js +0 -446
- package/test/transmission/to-zashiki/transform-root-schema/with-values/with-params/transforming-object-type-schemas.spec.js +0 -8348
- package/test/transmission/to-zashiki/transform-root-schema/with-values/with-params/transforming-string-type-schemas.spec.js +0 -446
- package/test/transmission/to-zashiki/transform-root-schema/with-values/without-params/transforming-array-type-schemas.spec.js +0 -30373
- package/test/transmission/to-zashiki/transform-root-schema/with-values/without-params/transforming-boolean-type-schemas.spec.js +0 -334
- package/test/transmission/to-zashiki/transform-root-schema/with-values/without-params/transforming-null-type-schemas.spec.js +0 -253
- package/test/transmission/to-zashiki/transform-root-schema/with-values/without-params/transforming-number-type-schemas.spec.js +0 -421
- package/test/transmission/to-zashiki/transform-root-schema/with-values/without-params/transforming-object-type-schemas.spec.js +0 -7826
- package/test/transmission/to-zashiki/transform-root-schema/with-values/without-params/transforming-string-type-schemas.spec.js +0 -421
- package/test/transmission/to-zashiki/transform-root-schema/without-values/with-params/transforming-array-type-schemas.spec.js +0 -31111
- package/test/transmission/to-zashiki/transform-root-schema/without-values/with-params/transforming-boolean-type-schemas.spec.js +0 -347
- package/test/transmission/to-zashiki/transform-root-schema/without-values/with-params/transforming-null-type-schemas.spec.js +0 -344
- package/test/transmission/to-zashiki/transform-root-schema/without-values/with-params/transforming-number-type-schemas.spec.js +0 -434
- package/test/transmission/to-zashiki/transform-root-schema/without-values/with-params/transforming-object-type-schemas.spec.js +0 -8222
- package/test/transmission/to-zashiki/transform-root-schema/without-values/with-params/transforming-string-type-schemas.spec.js +0 -434
- package/test/transmission/to-zashiki/transform-root-schema/without-values/without-params/transforming-array-type-schemas.spec.js +0 -29494
- package/test/transmission/to-zashiki/transform-root-schema/without-values/without-params/transforming-boolean-type-schemas.spec.js +0 -312
- package/test/transmission/to-zashiki/transform-root-schema/without-values/without-params/transforming-null-type-schemas.spec.js +0 -309
- package/test/transmission/to-zashiki/transform-root-schema/without-values/without-params/transforming-number-type-schemas.spec.js +0 -399
- package/test/transmission/to-zashiki/transform-root-schema/without-values/without-params/transforming-object-type-schemas.spec.js +0 -7584
- package/test/transmission/to-zashiki/transform-root-schema/without-values/without-params/transforming-string-type-schemas.spec.js +0 -398
- package/test/transmission/to-zashiki/transform-root-schema.spec.js +0 -22
- package/test/transmission/to-zashiki/transform-schema/transforming-array-type-schemas.spec.js +0 -1806
- package/test/transmission/to-zashiki/transform-schema/transforming-boolean-type-schemas.spec.js +0 -340
- package/test/transmission/to-zashiki/transform-schema/transforming-null-type-schemas.spec.js +0 -259
- package/test/transmission/to-zashiki/transform-schema/transforming-number-type-schemas.spec.js +0 -571
- package/test/transmission/to-zashiki/transform-schema/transforming-object-type-schemas.spec.js +0 -1737
- package/test/transmission/to-zashiki/transform-schema/transforming-string-type-schemas.spec.js +0 -502
- package/test/transmission/to-zashiki/transform-schema/with-values/with-params/transforming-array-type-schemas.spec.js +0 -32173
- package/test/transmission/to-zashiki/transform-schema/with-values/with-params/transforming-boolean-type-schemas.spec.js +0 -377
- package/test/transmission/to-zashiki/transform-schema/with-values/with-params/transforming-null-type-schemas.spec.js +0 -377
- package/test/transmission/to-zashiki/transform-schema/with-values/with-params/transforming-number-type-schemas.spec.js +0 -464
- package/test/transmission/to-zashiki/transform-schema/with-values/with-params/transforming-object-type-schemas.spec.js +0 -8525
- package/test/transmission/to-zashiki/transform-schema/with-values/with-params/transforming-string-type-schemas.spec.js +0 -464
- package/test/transmission/to-zashiki/transform-schema/with-values/without-params/transforming-array-type-schemas.spec.js +0 -30910
- package/test/transmission/to-zashiki/transform-schema/with-values/without-params/transforming-boolean-type-schemas.spec.js +0 -352
- package/test/transmission/to-zashiki/transform-schema/with-values/without-params/transforming-null-type-schemas.spec.js +0 -271
- package/test/transmission/to-zashiki/transform-schema/with-values/without-params/transforming-number-type-schemas.spec.js +0 -439
- package/test/transmission/to-zashiki/transform-schema/with-values/without-params/transforming-object-type-schemas.spec.js +0 -8003
- package/test/transmission/to-zashiki/transform-schema/with-values/without-params/transforming-string-type-schemas.spec.js +0 -439
- package/test/transmission/to-zashiki/transform-schema/without-values/with-params/transforming-array-type-schemas.spec.js +0 -31654
- package/test/transmission/to-zashiki/transform-schema/without-values/with-params/transforming-boolean-type-schemas.spec.js +0 -365
- package/test/transmission/to-zashiki/transform-schema/without-values/with-params/transforming-null-type-schemas.spec.js +0 -362
- package/test/transmission/to-zashiki/transform-schema/without-values/with-params/transforming-number-type-schemas.spec.js +0 -452
- package/test/transmission/to-zashiki/transform-schema/without-values/with-params/transforming-object-type-schemas.spec.js +0 -8399
- package/test/transmission/to-zashiki/transform-schema/without-values/with-params/transforming-string-type-schemas.spec.js +0 -452
- package/test/transmission/to-zashiki/transform-schema/without-values/without-params/transforming-array-type-schemas.spec.js +0 -29671
- package/test/transmission/to-zashiki/transform-schema/without-values/without-params/transforming-boolean-type-schemas.spec.js +0 -320
- package/test/transmission/to-zashiki/transform-schema/without-values/without-params/transforming-null-type-schemas.spec.js +0 -317
- package/test/transmission/to-zashiki/transform-schema/without-values/without-params/transforming-number-type-schemas.spec.js +0 -407
- package/test/transmission/to-zashiki/transform-schema/without-values/without-params/transforming-object-type-schemas.spec.js +0 -7645
- package/test/transmission/to-zashiki/transform-schema/without-values/without-params/transforming-string-type-schemas.spec.js +0 -406
- package/test/transmission/to-zashiki/transform-schema.spec.js +0 -777
@@ -1,1866 +0,0 @@
|
|
1
|
-
import debug from 'debug'
|
2
|
-
|
3
|
-
import { expect } from 'chai'
|
4
|
-
|
5
|
-
import transform from 'shinkansen-transmission/transmission/from-document-to-hash'
|
6
|
-
|
7
|
-
describe('shinkansen-transmission/transmission/from-document-to-hash', () => {
|
8
|
-
before(() => {
|
9
|
-
const {
|
10
|
-
env: {
|
11
|
-
DEBUG
|
12
|
-
}
|
13
|
-
} = process
|
14
|
-
|
15
|
-
if (DEBUG) debug.enable(DEBUG)
|
16
|
-
})
|
17
|
-
|
18
|
-
it('is a function', () => {
|
19
|
-
expect(transform)
|
20
|
-
.to.be.a('function')
|
21
|
-
})
|
22
|
-
|
23
|
-
it('transforms', () => {
|
24
|
-
const document = {
|
25
|
-
stringTypeSubSchema: 'mock string',
|
26
|
-
numberTypeSubSchema: 1,
|
27
|
-
arrayTypeSubSchema: [
|
28
|
-
'mock array string'
|
29
|
-
],
|
30
|
-
objectTypeSubSchema: {
|
31
|
-
one: 'mock object string',
|
32
|
-
two: 2
|
33
|
-
},
|
34
|
-
booleanTypeSubSchema: true,
|
35
|
-
nullTypeSubSchema: null,
|
36
|
-
latitude: 84,
|
37
|
-
longitude: -90,
|
38
|
-
array: [[[1]]],
|
39
|
-
object: {
|
40
|
-
a: { b: { c: 'D' } }
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
const schema = {
|
45
|
-
$id: 'https://example.com/geographical-location.schema.json',
|
46
|
-
$schema: 'http://json-schema.org/draft-07/schema#',
|
47
|
-
title: 'Latitude and Longitude',
|
48
|
-
description: 'A geographical coordinate',
|
49
|
-
required: ['latitude', 'longitude'],
|
50
|
-
type: 'object',
|
51
|
-
properties: {
|
52
|
-
stringTypeSubSchema: {
|
53
|
-
title: 'String type sub schema',
|
54
|
-
type: 'string',
|
55
|
-
minLength: 1,
|
56
|
-
maxLength: 10
|
57
|
-
},
|
58
|
-
numberTypeSubSchema: {
|
59
|
-
title: 'Number type sub schema',
|
60
|
-
type: 'number',
|
61
|
-
min: 1,
|
62
|
-
max: 10
|
63
|
-
},
|
64
|
-
arrayTypeSubSchema: {
|
65
|
-
title: 'Array type sub schema',
|
66
|
-
type: 'array',
|
67
|
-
items: [
|
68
|
-
{
|
69
|
-
type: 'string'
|
70
|
-
}
|
71
|
-
]
|
72
|
-
},
|
73
|
-
objectTypeSubSchema: {
|
74
|
-
title: 'Object type sub schema',
|
75
|
-
type: 'object',
|
76
|
-
properties: {
|
77
|
-
one: { type: 'string' },
|
78
|
-
two: { type: 'number' }
|
79
|
-
}
|
80
|
-
},
|
81
|
-
booleanTypeSubSchema: {
|
82
|
-
title: 'Boolean type sub schema',
|
83
|
-
type: 'boolean'
|
84
|
-
},
|
85
|
-
nullTypeSubSchema: {
|
86
|
-
title: 'Null type sub schema',
|
87
|
-
type: 'null'
|
88
|
-
},
|
89
|
-
latitude: {
|
90
|
-
title: 'Latitude',
|
91
|
-
type: 'number',
|
92
|
-
minimum: -90,
|
93
|
-
maximum: 90,
|
94
|
-
multipleOf: 42.0
|
95
|
-
},
|
96
|
-
longitude: {
|
97
|
-
title: 'Longitude',
|
98
|
-
type: 'number',
|
99
|
-
minimum: -180,
|
100
|
-
maximum: 180,
|
101
|
-
exclusiveMinimum: true,
|
102
|
-
exclusiveMaximum: true
|
103
|
-
},
|
104
|
-
array: {
|
105
|
-
type: 'array',
|
106
|
-
items: [
|
107
|
-
{
|
108
|
-
type: 'array',
|
109
|
-
items: [
|
110
|
-
{
|
111
|
-
type: 'array',
|
112
|
-
items: [
|
113
|
-
{
|
114
|
-
type: 'number'
|
115
|
-
}
|
116
|
-
]
|
117
|
-
}
|
118
|
-
]
|
119
|
-
}
|
120
|
-
]
|
121
|
-
},
|
122
|
-
object: {
|
123
|
-
type: 'object',
|
124
|
-
properties: {
|
125
|
-
a: {
|
126
|
-
type: 'object',
|
127
|
-
properties: {
|
128
|
-
b: {
|
129
|
-
type: 'object',
|
130
|
-
properties: {
|
131
|
-
c: {
|
132
|
-
type: 'string'
|
133
|
-
}
|
134
|
-
}
|
135
|
-
}
|
136
|
-
}
|
137
|
-
}
|
138
|
-
}
|
139
|
-
}
|
140
|
-
}
|
141
|
-
}
|
142
|
-
|
143
|
-
const values = {
|
144
|
-
'#/stringTypeSubSchema': 'mock string',
|
145
|
-
'#/numberTypeSubSchema': '1',
|
146
|
-
'#/arrayTypeSubSchema/0': 'mock array string',
|
147
|
-
'#/objectTypeSubSchema/one': 'mock object string',
|
148
|
-
'#/objectTypeSubSchema/two': '2',
|
149
|
-
'#/booleanTypeSubSchema': 'true',
|
150
|
-
'#/nullTypeSubSchema': 'null',
|
151
|
-
'#/latitude': '84',
|
152
|
-
'#/longitude': '-90',
|
153
|
-
'#/array/0/0/0': '1',
|
154
|
-
'#/object/a/b/c': 'D'
|
155
|
-
}
|
156
|
-
|
157
|
-
return expect(transform(document, schema))
|
158
|
-
.to.eql(values)
|
159
|
-
})
|
160
|
-
|
161
|
-
describe('Transforming `string` type schemas', () => {
|
162
|
-
it('transforms `string` type schemas with `enum`', () => {
|
163
|
-
const document = 'mock string (2)'
|
164
|
-
|
165
|
-
const schema = { type: 'string', enum: ['mock string (1)', 'mock string (2)'] }
|
166
|
-
|
167
|
-
const values = {
|
168
|
-
'#/': '1'
|
169
|
-
}
|
170
|
-
|
171
|
-
return expect(transform(document, schema))
|
172
|
-
.to.eql(values)
|
173
|
-
})
|
174
|
-
|
175
|
-
it('transforms `string` type schemas without `enum`', () => {
|
176
|
-
const document = 'mock string'
|
177
|
-
|
178
|
-
const schema = { type: 'string' }
|
179
|
-
|
180
|
-
const values = {
|
181
|
-
'#/': 'mock string'
|
182
|
-
}
|
183
|
-
|
184
|
-
return expect(transform(document, schema))
|
185
|
-
.to.eql(values)
|
186
|
-
})
|
187
|
-
})
|
188
|
-
|
189
|
-
describe('Transforming `number` type schemas', () => {
|
190
|
-
it('transforms `number` type schemas with `enum`', () => {
|
191
|
-
const document = 3
|
192
|
-
|
193
|
-
const schema = { type: 'number', enum: [1, 2, 3] }
|
194
|
-
|
195
|
-
const values = {
|
196
|
-
'#/': '2'
|
197
|
-
}
|
198
|
-
|
199
|
-
return expect(transform(document, schema))
|
200
|
-
.to.eql(values)
|
201
|
-
})
|
202
|
-
|
203
|
-
it('transforms `number` type schemas without `enum`', () => {
|
204
|
-
const document = 1
|
205
|
-
|
206
|
-
const schema = { type: 'number' }
|
207
|
-
|
208
|
-
const values = {
|
209
|
-
'#/': '1'
|
210
|
-
}
|
211
|
-
|
212
|
-
return expect(transform(document, schema))
|
213
|
-
.to.eql(values)
|
214
|
-
})
|
215
|
-
})
|
216
|
-
|
217
|
-
describe('Transforming `array` type schemas', () => {
|
218
|
-
it('transforms `array` type schemas with `enum` (`items` is an array of `string` type)', () => {
|
219
|
-
const document = ['mock array type index string (two)']
|
220
|
-
|
221
|
-
const schema = {
|
222
|
-
type: 'array',
|
223
|
-
items: [
|
224
|
-
{
|
225
|
-
type: 'string',
|
226
|
-
enum: [
|
227
|
-
'mock array type index string (one)',
|
228
|
-
'mock array type index string (two)'
|
229
|
-
]
|
230
|
-
}
|
231
|
-
]
|
232
|
-
}
|
233
|
-
|
234
|
-
const values = {
|
235
|
-
'#/0': '1'
|
236
|
-
}
|
237
|
-
|
238
|
-
return expect(transform(document, schema))
|
239
|
-
.to.eql(values)
|
240
|
-
})
|
241
|
-
|
242
|
-
it('transforms `array` type schemas with `enum` (`items` is an array of `number` type)', () => {
|
243
|
-
const document = [3]
|
244
|
-
|
245
|
-
const schema = {
|
246
|
-
type: 'array',
|
247
|
-
items: [
|
248
|
-
{
|
249
|
-
type: 'number',
|
250
|
-
enum: [1, 2, 3]
|
251
|
-
}
|
252
|
-
]
|
253
|
-
}
|
254
|
-
|
255
|
-
const values = {
|
256
|
-
'#/0': '2'
|
257
|
-
}
|
258
|
-
|
259
|
-
return expect(transform(document, schema))
|
260
|
-
.to.eql(values)
|
261
|
-
})
|
262
|
-
|
263
|
-
it('transforms `array` type schemas with `enum` (`items` is an array of `array` type and `items` is an array of `string` type)', () => {
|
264
|
-
const document = [['mock array type index string (two)']]
|
265
|
-
|
266
|
-
const schema = {
|
267
|
-
type: 'array',
|
268
|
-
items: [
|
269
|
-
{
|
270
|
-
type: 'array',
|
271
|
-
items: [
|
272
|
-
{
|
273
|
-
type: 'string',
|
274
|
-
enum: [
|
275
|
-
'mock array type index string (one)',
|
276
|
-
'mock array type index string (two)'
|
277
|
-
]
|
278
|
-
}
|
279
|
-
]
|
280
|
-
}
|
281
|
-
]
|
282
|
-
}
|
283
|
-
|
284
|
-
const values = {
|
285
|
-
'#/0/0': '1'
|
286
|
-
}
|
287
|
-
|
288
|
-
return expect(transform(document, schema))
|
289
|
-
.to.eql(values)
|
290
|
-
})
|
291
|
-
|
292
|
-
it('transforms `array` type schemas with `enum` (`items` is an array of `array` type and `items` is an array of `number` type)', () => {
|
293
|
-
const document = [[2]]
|
294
|
-
|
295
|
-
const schema = {
|
296
|
-
type: 'array',
|
297
|
-
items: [
|
298
|
-
{
|
299
|
-
type: 'array',
|
300
|
-
items: [
|
301
|
-
{
|
302
|
-
type: 'number',
|
303
|
-
enum: [
|
304
|
-
1,
|
305
|
-
2
|
306
|
-
]
|
307
|
-
}
|
308
|
-
]
|
309
|
-
}
|
310
|
-
]
|
311
|
-
}
|
312
|
-
|
313
|
-
const values = {
|
314
|
-
'#/0/0': '1'
|
315
|
-
}
|
316
|
-
|
317
|
-
return expect(transform(document, schema))
|
318
|
-
.to.eql(values)
|
319
|
-
})
|
320
|
-
|
321
|
-
it('transforms `array` type schemas with `enum` (`items` is an array of `array` type and `items` is an array of `boolean` type)', () => {
|
322
|
-
const document = [[false]]
|
323
|
-
|
324
|
-
const schema = {
|
325
|
-
type: 'array',
|
326
|
-
items: [
|
327
|
-
{
|
328
|
-
type: 'array',
|
329
|
-
items: [
|
330
|
-
{
|
331
|
-
type: 'boolean',
|
332
|
-
enum: [
|
333
|
-
true,
|
334
|
-
false
|
335
|
-
]
|
336
|
-
}
|
337
|
-
]
|
338
|
-
}
|
339
|
-
]
|
340
|
-
}
|
341
|
-
|
342
|
-
const values = {
|
343
|
-
'#/0/0': '1'
|
344
|
-
}
|
345
|
-
|
346
|
-
return expect(transform(document, schema))
|
347
|
-
.to.eql(values)
|
348
|
-
})
|
349
|
-
|
350
|
-
it('transforms `array` type schemas with `enum` (`items` is an array of `array` type and `items` is an array of `null` type)', () => {
|
351
|
-
const document = [[null]]
|
352
|
-
|
353
|
-
const schema = {
|
354
|
-
type: 'array',
|
355
|
-
items: [
|
356
|
-
{
|
357
|
-
type: 'array',
|
358
|
-
items: [
|
359
|
-
{
|
360
|
-
type: 'null',
|
361
|
-
enum: [
|
362
|
-
null
|
363
|
-
]
|
364
|
-
}
|
365
|
-
]
|
366
|
-
}
|
367
|
-
]
|
368
|
-
}
|
369
|
-
|
370
|
-
const values = {
|
371
|
-
'#/0/0': '0'
|
372
|
-
}
|
373
|
-
|
374
|
-
return expect(transform(document, schema))
|
375
|
-
.to.eql(values)
|
376
|
-
})
|
377
|
-
|
378
|
-
it('transforms `array` type schemas with `enum` (`items` is an array of `array` type and `items` is an object of `string` type)', () => {
|
379
|
-
const document = [['mock array type index string (two)']]
|
380
|
-
|
381
|
-
const schema = {
|
382
|
-
type: 'array',
|
383
|
-
items: [
|
384
|
-
{
|
385
|
-
type: 'array',
|
386
|
-
items: {
|
387
|
-
type: 'string',
|
388
|
-
enum: [
|
389
|
-
'mock array type index string (one)',
|
390
|
-
'mock array type index string (two)'
|
391
|
-
]
|
392
|
-
}
|
393
|
-
}
|
394
|
-
]
|
395
|
-
}
|
396
|
-
|
397
|
-
const values = {
|
398
|
-
'#/0': ['1']
|
399
|
-
}
|
400
|
-
|
401
|
-
return expect(transform(document, schema))
|
402
|
-
.to.eql(values)
|
403
|
-
})
|
404
|
-
|
405
|
-
it('transforms `array` type schemas with `enum` (`items` is an array of `array` type and `items` is an object of `number` type)', () => {
|
406
|
-
const document = [[2]]
|
407
|
-
|
408
|
-
const schema = {
|
409
|
-
type: 'array',
|
410
|
-
items: [
|
411
|
-
{
|
412
|
-
type: 'array',
|
413
|
-
items: {
|
414
|
-
type: 'number',
|
415
|
-
enum: [
|
416
|
-
1,
|
417
|
-
2
|
418
|
-
]
|
419
|
-
}
|
420
|
-
}
|
421
|
-
]
|
422
|
-
}
|
423
|
-
|
424
|
-
const values = {
|
425
|
-
'#/0': ['1']
|
426
|
-
}
|
427
|
-
|
428
|
-
return expect(transform(document, schema))
|
429
|
-
.to.eql(values)
|
430
|
-
})
|
431
|
-
|
432
|
-
it('transforms `array` type schemas with `enum` (`items` is an array of `array` type and `items` is an object of `boolean` type)', () => {
|
433
|
-
const document = [[false]]
|
434
|
-
|
435
|
-
const schema = {
|
436
|
-
type: 'array',
|
437
|
-
items: [
|
438
|
-
{
|
439
|
-
type: 'array',
|
440
|
-
items: {
|
441
|
-
type: 'boolean',
|
442
|
-
enum: [
|
443
|
-
true,
|
444
|
-
false
|
445
|
-
]
|
446
|
-
}
|
447
|
-
}
|
448
|
-
]
|
449
|
-
}
|
450
|
-
|
451
|
-
const values = {
|
452
|
-
'#/0': ['1']
|
453
|
-
}
|
454
|
-
|
455
|
-
return expect(transform(document, schema))
|
456
|
-
.to.eql(values)
|
457
|
-
})
|
458
|
-
|
459
|
-
it('transforms `array` type schemas with `enum` (`items` is an array of `array` type and `items` is an object of `null` type)', () => {
|
460
|
-
const document = [[null]]
|
461
|
-
|
462
|
-
const schema = {
|
463
|
-
type: 'array',
|
464
|
-
items: [
|
465
|
-
{
|
466
|
-
type: 'array',
|
467
|
-
items: {
|
468
|
-
type: 'null',
|
469
|
-
enum: [
|
470
|
-
null
|
471
|
-
]
|
472
|
-
}
|
473
|
-
}
|
474
|
-
]
|
475
|
-
}
|
476
|
-
|
477
|
-
const values = {
|
478
|
-
'#/0': ['0'] // #/0/0': '0'
|
479
|
-
}
|
480
|
-
|
481
|
-
return expect(transform(document, schema))
|
482
|
-
.to.eql(values)
|
483
|
-
})
|
484
|
-
|
485
|
-
it('transforms `array` type schemas with `enum` (`items` is an array of `array` type and `items` is an object of `array` type and `items` is an object of `string` type', () => {
|
486
|
-
const document = [['a', 'b', 'c']]
|
487
|
-
|
488
|
-
const schema = {
|
489
|
-
type: 'array',
|
490
|
-
items: [
|
491
|
-
{
|
492
|
-
type: 'array',
|
493
|
-
items: {
|
494
|
-
type: 'string',
|
495
|
-
enum: [
|
496
|
-
'a',
|
497
|
-
'b',
|
498
|
-
'c'
|
499
|
-
]
|
500
|
-
}
|
501
|
-
}
|
502
|
-
]
|
503
|
-
}
|
504
|
-
|
505
|
-
const values = {
|
506
|
-
'#/0': ['0', '1', '2']
|
507
|
-
}
|
508
|
-
|
509
|
-
expect(transform(document, schema))
|
510
|
-
.to.eql(values)
|
511
|
-
})
|
512
|
-
|
513
|
-
it('transforms `array` type schemas with `enum` (`items` is an array of `array` type and `items` is an object of `array` type and `items` is an object of `number` type', () => {
|
514
|
-
const document = [[1, 2, 3]]
|
515
|
-
|
516
|
-
const schema = {
|
517
|
-
type: 'array',
|
518
|
-
items: [
|
519
|
-
{
|
520
|
-
type: 'array',
|
521
|
-
items: {
|
522
|
-
type: 'number',
|
523
|
-
enum: [
|
524
|
-
1,
|
525
|
-
2,
|
526
|
-
3
|
527
|
-
]
|
528
|
-
}
|
529
|
-
}
|
530
|
-
]
|
531
|
-
}
|
532
|
-
|
533
|
-
const values = {
|
534
|
-
'#/0': ['0', '1', '2']
|
535
|
-
}
|
536
|
-
|
537
|
-
expect(transform(document, schema))
|
538
|
-
.to.eql(values)
|
539
|
-
})
|
540
|
-
|
541
|
-
it('transforms `array` type schemas with `enum` (`items` is an array of `array` type and `items` is an object of `array` type and `items` is an object of `boolean` type', () => {
|
542
|
-
const document = [[true, false, true]]
|
543
|
-
|
544
|
-
const schema = {
|
545
|
-
type: 'array',
|
546
|
-
items: [
|
547
|
-
{
|
548
|
-
type: 'array',
|
549
|
-
items: {
|
550
|
-
type: 'number',
|
551
|
-
enum: [
|
552
|
-
true,
|
553
|
-
false
|
554
|
-
]
|
555
|
-
}
|
556
|
-
}
|
557
|
-
]
|
558
|
-
}
|
559
|
-
|
560
|
-
const values = {
|
561
|
-
'#/0': ['0', '1', '0']
|
562
|
-
}
|
563
|
-
|
564
|
-
expect(transform(document, schema))
|
565
|
-
.to.eql(values)
|
566
|
-
})
|
567
|
-
|
568
|
-
it('transforms `array` type schemas with `enum` (`items` is an array of `array` type and `items` is an object of `array` type and `items` is an object of `boolean` type', () => {
|
569
|
-
const document = [[null, null, null]]
|
570
|
-
|
571
|
-
const schema = {
|
572
|
-
type: 'array',
|
573
|
-
items: [
|
574
|
-
{
|
575
|
-
type: 'array',
|
576
|
-
items: {
|
577
|
-
type: 'number',
|
578
|
-
enum: [
|
579
|
-
null
|
580
|
-
]
|
581
|
-
}
|
582
|
-
}
|
583
|
-
]
|
584
|
-
}
|
585
|
-
|
586
|
-
const values = {
|
587
|
-
'#/0': ['0', '0', '0']
|
588
|
-
}
|
589
|
-
|
590
|
-
expect(transform(document, schema))
|
591
|
-
.to.eql(values)
|
592
|
-
})
|
593
|
-
|
594
|
-
it('transforms `array` type schemas with `enum` (`items` is an array of `object` type)', () => {
|
595
|
-
const document = [
|
596
|
-
{
|
597
|
-
one: 'mock array type index object type key string (1)',
|
598
|
-
two: 'mock array type index object type key string (2)'
|
599
|
-
}
|
600
|
-
]
|
601
|
-
|
602
|
-
const schema = {
|
603
|
-
type: 'array',
|
604
|
-
items: [
|
605
|
-
{
|
606
|
-
type: 'object',
|
607
|
-
properties: {
|
608
|
-
one: {
|
609
|
-
type: 'string',
|
610
|
-
enum: [
|
611
|
-
'mock array type index object type key string (1)',
|
612
|
-
'mock array type index object type key string (2)'
|
613
|
-
]
|
614
|
-
},
|
615
|
-
two: {
|
616
|
-
type: 'string',
|
617
|
-
enum: [
|
618
|
-
'mock array type index object type key string (1)',
|
619
|
-
'mock array type index object type key string (2)'
|
620
|
-
]
|
621
|
-
}
|
622
|
-
}
|
623
|
-
}
|
624
|
-
]
|
625
|
-
}
|
626
|
-
|
627
|
-
const values = {
|
628
|
-
'#/0/one': '0',
|
629
|
-
'#/0/two': '1'
|
630
|
-
}
|
631
|
-
|
632
|
-
return expect(transform(document, schema))
|
633
|
-
.to.eql(values)
|
634
|
-
})
|
635
|
-
|
636
|
-
it('transforms `array` type schemas with `enum` (`items` is an array of `boolean` type)', () => {
|
637
|
-
const document = [false]
|
638
|
-
|
639
|
-
const schema = {
|
640
|
-
type: 'array',
|
641
|
-
items: [
|
642
|
-
{
|
643
|
-
type: 'boolean',
|
644
|
-
enum: [
|
645
|
-
true,
|
646
|
-
false
|
647
|
-
]
|
648
|
-
}
|
649
|
-
]
|
650
|
-
}
|
651
|
-
|
652
|
-
const values = {
|
653
|
-
'#/0': '1'
|
654
|
-
}
|
655
|
-
|
656
|
-
return expect(transform(document, schema))
|
657
|
-
.to.eql(values)
|
658
|
-
})
|
659
|
-
|
660
|
-
it('transforms `array` type schemas with `enum` (`items` is an array of `null` type)', () => {
|
661
|
-
const document = [null]
|
662
|
-
|
663
|
-
const schema = {
|
664
|
-
type: 'array',
|
665
|
-
items: [
|
666
|
-
{
|
667
|
-
type: 'null',
|
668
|
-
enum: [
|
669
|
-
null
|
670
|
-
]
|
671
|
-
}
|
672
|
-
]
|
673
|
-
}
|
674
|
-
|
675
|
-
const values = {
|
676
|
-
'#/0': '0'
|
677
|
-
}
|
678
|
-
|
679
|
-
return expect(transform(document, schema))
|
680
|
-
.to.eql(values)
|
681
|
-
})
|
682
|
-
|
683
|
-
it('transforms `array` type schemas with `enum` (`items` is an array)', () => {
|
684
|
-
const document = ['string (3)', 3]
|
685
|
-
|
686
|
-
const schema = {
|
687
|
-
type: 'array',
|
688
|
-
items: [
|
689
|
-
{
|
690
|
-
type: 'string',
|
691
|
-
enum: [
|
692
|
-
'string (1)',
|
693
|
-
'string (2)',
|
694
|
-
'string (3)'
|
695
|
-
]
|
696
|
-
},
|
697
|
-
{
|
698
|
-
type: 'number',
|
699
|
-
enum: [
|
700
|
-
1,
|
701
|
-
2,
|
702
|
-
3
|
703
|
-
]
|
704
|
-
}
|
705
|
-
]
|
706
|
-
}
|
707
|
-
|
708
|
-
const values = {
|
709
|
-
'#/0': '2',
|
710
|
-
'#/1': '2'
|
711
|
-
}
|
712
|
-
|
713
|
-
return expect(transform(document, schema))
|
714
|
-
.to.eql(values)
|
715
|
-
})
|
716
|
-
|
717
|
-
it('transforms `array` type schemas with `enum` (`items` is an object of `string` type)', () => {
|
718
|
-
const document = ['mock array type index string (two)']
|
719
|
-
|
720
|
-
const schema = {
|
721
|
-
type: 'array',
|
722
|
-
items: {
|
723
|
-
type: 'string',
|
724
|
-
enum: [
|
725
|
-
'mock array type index string (one)',
|
726
|
-
'mock array type index string (two)'
|
727
|
-
]
|
728
|
-
}
|
729
|
-
}
|
730
|
-
|
731
|
-
const values = {
|
732
|
-
'#/': ['1']
|
733
|
-
}
|
734
|
-
|
735
|
-
return expect(transform(document, schema))
|
736
|
-
.to.eql(values)
|
737
|
-
})
|
738
|
-
|
739
|
-
it('transforms `array` type schemas with `enum` (`items` is an object of `number` type)', () => {
|
740
|
-
const document = [3]
|
741
|
-
|
742
|
-
const schema = {
|
743
|
-
type: 'array',
|
744
|
-
items: {
|
745
|
-
type: 'number',
|
746
|
-
enum: [
|
747
|
-
1,
|
748
|
-
2,
|
749
|
-
3
|
750
|
-
]
|
751
|
-
}
|
752
|
-
}
|
753
|
-
|
754
|
-
const values = {
|
755
|
-
'#/': ['2']
|
756
|
-
}
|
757
|
-
|
758
|
-
return expect(transform(document, schema))
|
759
|
-
.to.eql(values)
|
760
|
-
})
|
761
|
-
|
762
|
-
it('transforms `array` type schemas with `enum` (`items` is an object of `array` type and `items` is an array of `string` type)', () => {
|
763
|
-
const document = [['mock array type index string (two)']]
|
764
|
-
|
765
|
-
const schema = {
|
766
|
-
type: 'array',
|
767
|
-
items: {
|
768
|
-
type: 'array',
|
769
|
-
items: [
|
770
|
-
{
|
771
|
-
type: 'string',
|
772
|
-
enum: [
|
773
|
-
'mock array type index string (one)',
|
774
|
-
'mock array type index string (two)'
|
775
|
-
]
|
776
|
-
}
|
777
|
-
]
|
778
|
-
}
|
779
|
-
}
|
780
|
-
|
781
|
-
const values = {
|
782
|
-
'#/0/0': '1'
|
783
|
-
}
|
784
|
-
|
785
|
-
return expect(transform(document, schema))
|
786
|
-
.to.eql(values)
|
787
|
-
})
|
788
|
-
|
789
|
-
it('transforms `array` type schemas with `enum` (`items` is an object of `array` type and `items` is an array of `number` type)', () => {
|
790
|
-
const document = [[2]]
|
791
|
-
|
792
|
-
const schema = {
|
793
|
-
type: 'array',
|
794
|
-
items: {
|
795
|
-
type: 'array',
|
796
|
-
items: [
|
797
|
-
{
|
798
|
-
type: 'number',
|
799
|
-
enum: [
|
800
|
-
1,
|
801
|
-
2
|
802
|
-
]
|
803
|
-
}
|
804
|
-
]
|
805
|
-
}
|
806
|
-
}
|
807
|
-
|
808
|
-
const values = {
|
809
|
-
'#/0/0': '1'
|
810
|
-
}
|
811
|
-
|
812
|
-
return expect(transform(document, schema))
|
813
|
-
.to.eql(values)
|
814
|
-
})
|
815
|
-
|
816
|
-
it('transforms `array` type schemas with `enum` (`items` is an object of `array` type and `items` is an array of `boolean` type)', () => {
|
817
|
-
const document = [[false]]
|
818
|
-
|
819
|
-
const schema = {
|
820
|
-
type: 'array',
|
821
|
-
items: {
|
822
|
-
type: 'array',
|
823
|
-
items: [
|
824
|
-
{
|
825
|
-
type: 'boolean',
|
826
|
-
enum: [
|
827
|
-
true,
|
828
|
-
false
|
829
|
-
]
|
830
|
-
}
|
831
|
-
]
|
832
|
-
}
|
833
|
-
}
|
834
|
-
|
835
|
-
const values = {
|
836
|
-
'#/0/0': '1'
|
837
|
-
}
|
838
|
-
|
839
|
-
return expect(transform(document, schema))
|
840
|
-
.to.eql(values)
|
841
|
-
})
|
842
|
-
|
843
|
-
it('transforms `array` type schemas with `enum` (`items` is an object of `array` type and `items` is an array of `null` type)', () => {
|
844
|
-
const document = [[null]]
|
845
|
-
|
846
|
-
const schema = {
|
847
|
-
type: 'array',
|
848
|
-
items: {
|
849
|
-
type: 'array',
|
850
|
-
items: [
|
851
|
-
{
|
852
|
-
type: 'null',
|
853
|
-
enum: [
|
854
|
-
null
|
855
|
-
]
|
856
|
-
}
|
857
|
-
]
|
858
|
-
}
|
859
|
-
}
|
860
|
-
|
861
|
-
const values = {
|
862
|
-
'#/0/0': '0'
|
863
|
-
}
|
864
|
-
|
865
|
-
return expect(transform(document, schema))
|
866
|
-
.to.eql(values)
|
867
|
-
})
|
868
|
-
|
869
|
-
it('transforms `array` type schemas with `enum` (`items` is an object of `array` type and `items` is an object of `string` type)', () => {
|
870
|
-
const document = [['mock array type index string (two)']]
|
871
|
-
|
872
|
-
const schema = {
|
873
|
-
type: 'array',
|
874
|
-
items: {
|
875
|
-
type: 'array',
|
876
|
-
items: {
|
877
|
-
type: 'string',
|
878
|
-
enum: [
|
879
|
-
'mock array type index string (one)',
|
880
|
-
'mock array type index string (two)'
|
881
|
-
]
|
882
|
-
}
|
883
|
-
}
|
884
|
-
}
|
885
|
-
|
886
|
-
const values = {
|
887
|
-
'#/0': ['1'] // #/0/0': '1'
|
888
|
-
}
|
889
|
-
|
890
|
-
return expect(transform(document, schema))
|
891
|
-
.to.eql(values)
|
892
|
-
})
|
893
|
-
|
894
|
-
it('transforms `array` type schemas with `enum` (`items` is an object of `array` type and `items` is an object of `number` type)', () => {
|
895
|
-
const document = [[2]]
|
896
|
-
|
897
|
-
const schema = {
|
898
|
-
type: 'array',
|
899
|
-
items: {
|
900
|
-
type: 'array',
|
901
|
-
items: {
|
902
|
-
type: 'number',
|
903
|
-
enum: [
|
904
|
-
1,
|
905
|
-
2
|
906
|
-
]
|
907
|
-
}
|
908
|
-
}
|
909
|
-
}
|
910
|
-
|
911
|
-
const values = {
|
912
|
-
'#/0': ['1'] // #/0/0': '1'
|
913
|
-
}
|
914
|
-
|
915
|
-
return expect(transform(document, schema))
|
916
|
-
.to.eql(values)
|
917
|
-
})
|
918
|
-
|
919
|
-
it('transforms `array` type schemas with `enum` (`items` is an object of `array` type and `items` is an object of `boolean` type)', () => {
|
920
|
-
const document = [[false]]
|
921
|
-
|
922
|
-
const schema = {
|
923
|
-
type: 'array',
|
924
|
-
items: {
|
925
|
-
type: 'array',
|
926
|
-
items: {
|
927
|
-
type: 'boolean',
|
928
|
-
enum: [
|
929
|
-
true,
|
930
|
-
false
|
931
|
-
]
|
932
|
-
}
|
933
|
-
}
|
934
|
-
}
|
935
|
-
|
936
|
-
const values = {
|
937
|
-
'#/0': ['1'] // #/0/0': '1'
|
938
|
-
}
|
939
|
-
|
940
|
-
return expect(transform(document, schema))
|
941
|
-
.to.eql(values)
|
942
|
-
})
|
943
|
-
|
944
|
-
it('transforms `array` type schemas with `enum` (`items` is an object of `array` type and `items` is an object of `null` type)', () => {
|
945
|
-
const document = [[null]]
|
946
|
-
|
947
|
-
const schema = {
|
948
|
-
type: 'array',
|
949
|
-
items: {
|
950
|
-
type: 'array',
|
951
|
-
items: {
|
952
|
-
type: 'null',
|
953
|
-
enum: [
|
954
|
-
null
|
955
|
-
]
|
956
|
-
}
|
957
|
-
}
|
958
|
-
}
|
959
|
-
|
960
|
-
const values = {
|
961
|
-
'#/0': ['0'] // #/0/0': '0'
|
962
|
-
}
|
963
|
-
|
964
|
-
return expect(transform(document, schema))
|
965
|
-
.to.eql(values)
|
966
|
-
})
|
967
|
-
|
968
|
-
it('transforms `array` type schemas with `enum` (`items` is an object of `array` type and `items` is an object of `array` type and `items` is an object of `string` type', () => {
|
969
|
-
const document = [['a', 'b', 'c']]
|
970
|
-
|
971
|
-
const schema = {
|
972
|
-
type: 'array',
|
973
|
-
items: {
|
974
|
-
type: 'array',
|
975
|
-
items: {
|
976
|
-
type: 'string',
|
977
|
-
enum: [
|
978
|
-
'a',
|
979
|
-
'b',
|
980
|
-
'c'
|
981
|
-
]
|
982
|
-
}
|
983
|
-
}
|
984
|
-
}
|
985
|
-
|
986
|
-
const values = {
|
987
|
-
'#/0': ['0', '1', '2']
|
988
|
-
}
|
989
|
-
|
990
|
-
expect(transform(document, schema))
|
991
|
-
.to.eql(values)
|
992
|
-
})
|
993
|
-
|
994
|
-
it('transforms `array` type schemas with `enum` (`items` is an object of `array` type and `items` is an object of `array` type and `items` is an object of `number` type', () => {
|
995
|
-
const document = [[1, 2, 3]]
|
996
|
-
|
997
|
-
const schema = {
|
998
|
-
type: 'array',
|
999
|
-
items: {
|
1000
|
-
type: 'array',
|
1001
|
-
items: {
|
1002
|
-
type: 'number',
|
1003
|
-
enum: [
|
1004
|
-
1,
|
1005
|
-
2,
|
1006
|
-
3
|
1007
|
-
]
|
1008
|
-
}
|
1009
|
-
}
|
1010
|
-
}
|
1011
|
-
|
1012
|
-
const values = {
|
1013
|
-
'#/0': ['0', '1', '2']
|
1014
|
-
}
|
1015
|
-
|
1016
|
-
expect(transform(document, schema))
|
1017
|
-
.to.eql(values)
|
1018
|
-
})
|
1019
|
-
|
1020
|
-
it('transforms `array` type schemas with `enum` (`items` is an object of `array` type and `items` is an object of `array` type and `items` is an object of `boolean` type', () => {
|
1021
|
-
const document = [[true, false, true]]
|
1022
|
-
|
1023
|
-
const schema = {
|
1024
|
-
type: 'array',
|
1025
|
-
items: {
|
1026
|
-
type: 'array',
|
1027
|
-
items: {
|
1028
|
-
type: 'number',
|
1029
|
-
enum: [
|
1030
|
-
true,
|
1031
|
-
false
|
1032
|
-
]
|
1033
|
-
}
|
1034
|
-
}
|
1035
|
-
}
|
1036
|
-
|
1037
|
-
const values = {
|
1038
|
-
'#/0': ['0', '1', '0']
|
1039
|
-
}
|
1040
|
-
|
1041
|
-
expect(transform(document, schema))
|
1042
|
-
.to.eql(values)
|
1043
|
-
})
|
1044
|
-
|
1045
|
-
it('transforms `array` type schemas with `enum` (`items` is an object of `array` type and `items` is an object of `array` type and `items` is an object of `boolean` type', () => {
|
1046
|
-
const document = [[null, null, null]]
|
1047
|
-
|
1048
|
-
const schema = {
|
1049
|
-
type: 'array',
|
1050
|
-
items: {
|
1051
|
-
type: 'array',
|
1052
|
-
items: {
|
1053
|
-
type: 'number',
|
1054
|
-
enum: [
|
1055
|
-
null
|
1056
|
-
]
|
1057
|
-
}
|
1058
|
-
}
|
1059
|
-
}
|
1060
|
-
|
1061
|
-
const values = {
|
1062
|
-
'#/0': ['0', '0', '0']
|
1063
|
-
}
|
1064
|
-
|
1065
|
-
expect(transform(document, schema))
|
1066
|
-
.to.eql(values)
|
1067
|
-
})
|
1068
|
-
|
1069
|
-
it('transforms `array` type schemas with `enum` (`items` is an object of `object` type)', () => {
|
1070
|
-
const document = [
|
1071
|
-
{
|
1072
|
-
one: 'mock array type index object type key string (1)',
|
1073
|
-
two: 'mock array type index object type key string (2)'
|
1074
|
-
}
|
1075
|
-
]
|
1076
|
-
|
1077
|
-
const schema = {
|
1078
|
-
type: 'array',
|
1079
|
-
items: {
|
1080
|
-
type: 'object',
|
1081
|
-
properties: {
|
1082
|
-
one: {
|
1083
|
-
type: 'string',
|
1084
|
-
enum: [
|
1085
|
-
'mock array type index object type key string (1)',
|
1086
|
-
'mock array type index object type key string (2)'
|
1087
|
-
]
|
1088
|
-
},
|
1089
|
-
two: {
|
1090
|
-
type: 'string',
|
1091
|
-
enum: [
|
1092
|
-
'mock array type index object type key string (1)',
|
1093
|
-
'mock array type index object type key string (2)'
|
1094
|
-
]
|
1095
|
-
}
|
1096
|
-
}
|
1097
|
-
}
|
1098
|
-
}
|
1099
|
-
|
1100
|
-
const values = {
|
1101
|
-
'#/0/one': '0',
|
1102
|
-
'#/0/two': '1'
|
1103
|
-
}
|
1104
|
-
|
1105
|
-
return expect(transform(document, schema))
|
1106
|
-
.to.eql(values)
|
1107
|
-
})
|
1108
|
-
|
1109
|
-
it('transforms `array` type schemas with `enum` (`items` is an object of `boolean` type)', () => {
|
1110
|
-
const document = [false]
|
1111
|
-
|
1112
|
-
const schema = {
|
1113
|
-
type: 'array',
|
1114
|
-
items: {
|
1115
|
-
type: 'boolean',
|
1116
|
-
enum: [
|
1117
|
-
true,
|
1118
|
-
false
|
1119
|
-
]
|
1120
|
-
}
|
1121
|
-
}
|
1122
|
-
|
1123
|
-
const values = {
|
1124
|
-
'#/': ['1']
|
1125
|
-
}
|
1126
|
-
|
1127
|
-
return expect(transform(document, schema))
|
1128
|
-
.to.eql(values)
|
1129
|
-
})
|
1130
|
-
|
1131
|
-
it('transforms `array` type schemas with `enum` (`items` is an object of `null` type)', () => {
|
1132
|
-
const document = [null]
|
1133
|
-
|
1134
|
-
const schema = {
|
1135
|
-
type: 'array',
|
1136
|
-
items: {
|
1137
|
-
type: 'null',
|
1138
|
-
enum: [
|
1139
|
-
null
|
1140
|
-
]
|
1141
|
-
}
|
1142
|
-
}
|
1143
|
-
|
1144
|
-
const values = {
|
1145
|
-
'#/': ['0']
|
1146
|
-
}
|
1147
|
-
|
1148
|
-
return expect(transform(document, schema))
|
1149
|
-
.to.eql(values)
|
1150
|
-
})
|
1151
|
-
|
1152
|
-
it('transforms `array` type schemas without `enum` (`items` is an array of `string` type)', () => {
|
1153
|
-
const document = ['mock array type index string']
|
1154
|
-
|
1155
|
-
const schema = {
|
1156
|
-
type: 'array',
|
1157
|
-
items: [
|
1158
|
-
{
|
1159
|
-
type: 'string'
|
1160
|
-
}
|
1161
|
-
]
|
1162
|
-
}
|
1163
|
-
|
1164
|
-
const values = {
|
1165
|
-
'#/0': 'mock array type index string'
|
1166
|
-
}
|
1167
|
-
|
1168
|
-
return expect(transform(document, schema))
|
1169
|
-
.to.eql(values)
|
1170
|
-
})
|
1171
|
-
|
1172
|
-
it('transforms `array` type schemas without `enum` (`items` is an array of `number` type)', () => {
|
1173
|
-
const document = [1]
|
1174
|
-
|
1175
|
-
const schema = {
|
1176
|
-
type: 'array',
|
1177
|
-
items: [
|
1178
|
-
{
|
1179
|
-
type: 'number'
|
1180
|
-
}
|
1181
|
-
]
|
1182
|
-
}
|
1183
|
-
|
1184
|
-
const values = {
|
1185
|
-
'#/0': '1'
|
1186
|
-
}
|
1187
|
-
|
1188
|
-
return expect(transform(document, schema))
|
1189
|
-
.to.eql(values)
|
1190
|
-
})
|
1191
|
-
|
1192
|
-
it('transforms `array` type schemas without `enum` (`items` is an array of `array` type and `items` is an array of `string` type)', () => {
|
1193
|
-
const document = [['string']]
|
1194
|
-
|
1195
|
-
const schema = {
|
1196
|
-
type: 'array',
|
1197
|
-
items: [
|
1198
|
-
{
|
1199
|
-
type: 'array',
|
1200
|
-
items: [
|
1201
|
-
{
|
1202
|
-
type: 'string'
|
1203
|
-
}
|
1204
|
-
]
|
1205
|
-
}
|
1206
|
-
]
|
1207
|
-
}
|
1208
|
-
|
1209
|
-
const values = {
|
1210
|
-
'#/0/0': 'string'
|
1211
|
-
}
|
1212
|
-
|
1213
|
-
return expect(transform(document, schema))
|
1214
|
-
.to.eql(values)
|
1215
|
-
})
|
1216
|
-
|
1217
|
-
it('transforms `array` type schemas without `enum` (`items` is an array of `array` type and `items` is an array of `number` type)', () => {
|
1218
|
-
const document = [[1]]
|
1219
|
-
|
1220
|
-
const schema = {
|
1221
|
-
type: 'array',
|
1222
|
-
items: [
|
1223
|
-
{
|
1224
|
-
type: 'array',
|
1225
|
-
items: [
|
1226
|
-
{
|
1227
|
-
type: 'number'
|
1228
|
-
}
|
1229
|
-
]
|
1230
|
-
}
|
1231
|
-
]
|
1232
|
-
}
|
1233
|
-
|
1234
|
-
const values = {
|
1235
|
-
'#/0/0': '1'
|
1236
|
-
}
|
1237
|
-
|
1238
|
-
return expect(transform(document, schema))
|
1239
|
-
.to.eql(values)
|
1240
|
-
})
|
1241
|
-
|
1242
|
-
it('transforms `array` type schemas without `enum` (`items` is an array of `array` type and `items` is an array of `boolean` type)', () => {
|
1243
|
-
const document = [[false]]
|
1244
|
-
|
1245
|
-
const schema = {
|
1246
|
-
type: 'array',
|
1247
|
-
items: [
|
1248
|
-
{
|
1249
|
-
type: 'array',
|
1250
|
-
items: [
|
1251
|
-
{
|
1252
|
-
type: 'boolean'
|
1253
|
-
}
|
1254
|
-
]
|
1255
|
-
}
|
1256
|
-
]
|
1257
|
-
}
|
1258
|
-
|
1259
|
-
const values = {
|
1260
|
-
'#/0/0': 'false'
|
1261
|
-
}
|
1262
|
-
|
1263
|
-
return expect(transform(document, schema))
|
1264
|
-
.to.eql(values)
|
1265
|
-
})
|
1266
|
-
|
1267
|
-
it('transforms `array` type schemas without `enum` (`items` is an array of `array` type and `items` is an array of `null` type)', () => {
|
1268
|
-
const document = [[null]]
|
1269
|
-
|
1270
|
-
const schema = {
|
1271
|
-
type: 'array',
|
1272
|
-
items: [
|
1273
|
-
{
|
1274
|
-
type: 'array',
|
1275
|
-
items: [
|
1276
|
-
{
|
1277
|
-
type: 'null'
|
1278
|
-
}
|
1279
|
-
]
|
1280
|
-
}
|
1281
|
-
]
|
1282
|
-
}
|
1283
|
-
|
1284
|
-
const values = {
|
1285
|
-
'#/0/0': 'null'
|
1286
|
-
}
|
1287
|
-
|
1288
|
-
return expect(transform(document, schema))
|
1289
|
-
.to.eql(values)
|
1290
|
-
})
|
1291
|
-
|
1292
|
-
it('transforms `array` type schemas without `enum` (`items` is an array of `array` type and `items` is an object of `string` type)', () => {
|
1293
|
-
const document = [['string']]
|
1294
|
-
|
1295
|
-
const schema = {
|
1296
|
-
type: 'array',
|
1297
|
-
items: [
|
1298
|
-
{
|
1299
|
-
type: 'array',
|
1300
|
-
items: {
|
1301
|
-
type: 'string'
|
1302
|
-
}
|
1303
|
-
}
|
1304
|
-
]
|
1305
|
-
}
|
1306
|
-
|
1307
|
-
const values = {
|
1308
|
-
'#/0/0': 'string'
|
1309
|
-
}
|
1310
|
-
|
1311
|
-
return expect(transform(document, schema))
|
1312
|
-
.to.eql(values)
|
1313
|
-
})
|
1314
|
-
|
1315
|
-
it('transforms `array` type schemas without `enum` (`items` is an array of `array` type and `items` is an object of `number` type)', () => {
|
1316
|
-
const document = [[1]]
|
1317
|
-
|
1318
|
-
const schema = {
|
1319
|
-
type: 'array',
|
1320
|
-
items: [
|
1321
|
-
{
|
1322
|
-
type: 'array',
|
1323
|
-
items: {
|
1324
|
-
type: 'number'
|
1325
|
-
}
|
1326
|
-
}
|
1327
|
-
]
|
1328
|
-
}
|
1329
|
-
|
1330
|
-
const values = {
|
1331
|
-
'#/0/0': '1'
|
1332
|
-
}
|
1333
|
-
|
1334
|
-
return expect(transform(document, schema))
|
1335
|
-
.to.eql(values)
|
1336
|
-
})
|
1337
|
-
|
1338
|
-
it('transforms `array` type schemas without `enum` (`items` is an array of `array` type and `items` is an object of `boolean` type)', () => {
|
1339
|
-
const document = [[false]]
|
1340
|
-
|
1341
|
-
const schema = {
|
1342
|
-
type: 'array',
|
1343
|
-
items: [
|
1344
|
-
{
|
1345
|
-
type: 'array',
|
1346
|
-
items: {
|
1347
|
-
type: 'boolean'
|
1348
|
-
}
|
1349
|
-
}
|
1350
|
-
]
|
1351
|
-
}
|
1352
|
-
|
1353
|
-
const values = {
|
1354
|
-
'#/0/0': 'false'
|
1355
|
-
}
|
1356
|
-
|
1357
|
-
return expect(transform(document, schema))
|
1358
|
-
.to.eql(values)
|
1359
|
-
})
|
1360
|
-
|
1361
|
-
it('transforms `array` type schemas without `enum` (`items` is an array of `array` type and `items` is an object of `null` type)', () => {
|
1362
|
-
const document = [[null]]
|
1363
|
-
|
1364
|
-
const schema = {
|
1365
|
-
type: 'array',
|
1366
|
-
items: [
|
1367
|
-
{
|
1368
|
-
type: 'array',
|
1369
|
-
items: {
|
1370
|
-
type: 'null'
|
1371
|
-
}
|
1372
|
-
}
|
1373
|
-
]
|
1374
|
-
}
|
1375
|
-
|
1376
|
-
const values = {
|
1377
|
-
'#/0/0': 'null'
|
1378
|
-
}
|
1379
|
-
|
1380
|
-
return expect(transform(document, schema))
|
1381
|
-
.to.eql(values)
|
1382
|
-
})
|
1383
|
-
|
1384
|
-
it('transforms `array` type schemas without `enum` (`items` is an array of `object` type)', () => {
|
1385
|
-
const document = [
|
1386
|
-
{
|
1387
|
-
one: 'mock array type index object type key string',
|
1388
|
-
two: '1'
|
1389
|
-
}
|
1390
|
-
]
|
1391
|
-
|
1392
|
-
const schema = {
|
1393
|
-
type: 'array',
|
1394
|
-
items: [
|
1395
|
-
{
|
1396
|
-
type: 'object',
|
1397
|
-
properties: {
|
1398
|
-
one: {
|
1399
|
-
type: 'string'
|
1400
|
-
},
|
1401
|
-
two: {
|
1402
|
-
type: 'number'
|
1403
|
-
}
|
1404
|
-
}
|
1405
|
-
}
|
1406
|
-
]
|
1407
|
-
}
|
1408
|
-
|
1409
|
-
const values = {
|
1410
|
-
'#/0/one': 'mock array type index object type key string',
|
1411
|
-
'#/0/two': '1'
|
1412
|
-
}
|
1413
|
-
|
1414
|
-
return expect(transform(document, schema))
|
1415
|
-
.to.eql(values)
|
1416
|
-
})
|
1417
|
-
|
1418
|
-
it('transforms `array` type schemas without `enum` (`items` is an array of `boolean` type)', () => {
|
1419
|
-
const document = [true]
|
1420
|
-
|
1421
|
-
const schema = {
|
1422
|
-
type: 'array',
|
1423
|
-
items: [
|
1424
|
-
{
|
1425
|
-
type: 'boolean'
|
1426
|
-
}
|
1427
|
-
]
|
1428
|
-
}
|
1429
|
-
|
1430
|
-
const values = {
|
1431
|
-
'#/0': 'true'
|
1432
|
-
}
|
1433
|
-
|
1434
|
-
return expect(transform(document, schema))
|
1435
|
-
.to.eql(values)
|
1436
|
-
})
|
1437
|
-
|
1438
|
-
it('transforms `array` type schemas without `enum` (`items` is an array of `null` type)', () => {
|
1439
|
-
const document = [null]
|
1440
|
-
|
1441
|
-
const schema = {
|
1442
|
-
type: 'array',
|
1443
|
-
items: [
|
1444
|
-
{
|
1445
|
-
type: 'null'
|
1446
|
-
}
|
1447
|
-
]
|
1448
|
-
}
|
1449
|
-
|
1450
|
-
const values = {
|
1451
|
-
'#/0': 'null'
|
1452
|
-
}
|
1453
|
-
|
1454
|
-
return expect(transform(document, schema))
|
1455
|
-
.to.eql(values)
|
1456
|
-
})
|
1457
|
-
|
1458
|
-
it('transforms `array` type schemas without `enum` (`items` is an array)', () => {
|
1459
|
-
const document = ['string', 2]
|
1460
|
-
|
1461
|
-
const schema = {
|
1462
|
-
type: 'array',
|
1463
|
-
items: [
|
1464
|
-
{
|
1465
|
-
type: 'string'
|
1466
|
-
},
|
1467
|
-
{
|
1468
|
-
type: 'number'
|
1469
|
-
}
|
1470
|
-
]
|
1471
|
-
}
|
1472
|
-
|
1473
|
-
const values = {
|
1474
|
-
'#/0': 'string',
|
1475
|
-
'#/1': '2'
|
1476
|
-
}
|
1477
|
-
|
1478
|
-
return expect(transform(document, schema))
|
1479
|
-
.to.eql(values)
|
1480
|
-
})
|
1481
|
-
|
1482
|
-
it('transforms `array` type schemas without `enum` (`items` is an object of `string` type)', () => {
|
1483
|
-
const document = ['mock array type index string']
|
1484
|
-
|
1485
|
-
const schema = {
|
1486
|
-
type: 'array',
|
1487
|
-
items: {
|
1488
|
-
type: 'string'
|
1489
|
-
}
|
1490
|
-
}
|
1491
|
-
|
1492
|
-
const values = {
|
1493
|
-
'#/0': 'mock array type index string'
|
1494
|
-
}
|
1495
|
-
|
1496
|
-
return expect(transform(document, schema))
|
1497
|
-
.to.eql(values)
|
1498
|
-
})
|
1499
|
-
|
1500
|
-
it('transforms `array` type schemas without `enum` (`items` is an object of `number` type)', () => {
|
1501
|
-
const document = [1]
|
1502
|
-
|
1503
|
-
const schema = {
|
1504
|
-
type: 'array',
|
1505
|
-
items: {
|
1506
|
-
type: 'number'
|
1507
|
-
}
|
1508
|
-
}
|
1509
|
-
|
1510
|
-
const values = {
|
1511
|
-
'#/0': '1'
|
1512
|
-
}
|
1513
|
-
|
1514
|
-
return expect(transform(document, schema))
|
1515
|
-
.to.eql(values)
|
1516
|
-
})
|
1517
|
-
|
1518
|
-
it('transforms `array` type schemas without `enum` (`items` is an object of `array` type and `items` is an array of `string` type)', () => {
|
1519
|
-
const document = [['string']]
|
1520
|
-
|
1521
|
-
const schema = {
|
1522
|
-
type: 'array',
|
1523
|
-
items: {
|
1524
|
-
type: 'array',
|
1525
|
-
items: [
|
1526
|
-
{
|
1527
|
-
type: 'string'
|
1528
|
-
}
|
1529
|
-
]
|
1530
|
-
}
|
1531
|
-
}
|
1532
|
-
|
1533
|
-
const values = {
|
1534
|
-
'#/0/0': 'string'
|
1535
|
-
}
|
1536
|
-
|
1537
|
-
return expect(transform(document, schema))
|
1538
|
-
.to.eql(values)
|
1539
|
-
})
|
1540
|
-
|
1541
|
-
it('transforms `array` type schemas without `enum` (`items` is an object of `array` type and `items` is an array of `number` type)', () => {
|
1542
|
-
const document = [[1]]
|
1543
|
-
|
1544
|
-
const schema = {
|
1545
|
-
type: 'array',
|
1546
|
-
items: {
|
1547
|
-
type: 'array',
|
1548
|
-
items: [
|
1549
|
-
{
|
1550
|
-
type: 'number'
|
1551
|
-
}
|
1552
|
-
]
|
1553
|
-
}
|
1554
|
-
}
|
1555
|
-
|
1556
|
-
const values = {
|
1557
|
-
'#/0/0': '1'
|
1558
|
-
}
|
1559
|
-
|
1560
|
-
return expect(transform(document, schema))
|
1561
|
-
.to.eql(values)
|
1562
|
-
})
|
1563
|
-
|
1564
|
-
it('transforms `array` type schemas without `enum` (`items` is an object of `array` type and `items` is an array of `boolean` type)', () => {
|
1565
|
-
const document = [[false]]
|
1566
|
-
|
1567
|
-
const schema = {
|
1568
|
-
type: 'array',
|
1569
|
-
items: {
|
1570
|
-
type: 'array',
|
1571
|
-
items: [
|
1572
|
-
{
|
1573
|
-
type: 'boolean'
|
1574
|
-
}
|
1575
|
-
]
|
1576
|
-
}
|
1577
|
-
}
|
1578
|
-
|
1579
|
-
const values = {
|
1580
|
-
'#/0/0': 'false'
|
1581
|
-
}
|
1582
|
-
|
1583
|
-
return expect(transform(document, schema))
|
1584
|
-
.to.eql(values)
|
1585
|
-
})
|
1586
|
-
|
1587
|
-
it('transforms `array` type schemas without `enum` (`items` is an object of `array` type and `items` is an array of `null` type)', () => {
|
1588
|
-
const document = [[null]]
|
1589
|
-
|
1590
|
-
const schema = {
|
1591
|
-
type: 'array',
|
1592
|
-
items: {
|
1593
|
-
type: 'array',
|
1594
|
-
items: [
|
1595
|
-
{
|
1596
|
-
type: 'null'
|
1597
|
-
}
|
1598
|
-
]
|
1599
|
-
}
|
1600
|
-
}
|
1601
|
-
|
1602
|
-
const values = {
|
1603
|
-
'#/0/0': 'null'
|
1604
|
-
}
|
1605
|
-
|
1606
|
-
return expect(transform(document, schema))
|
1607
|
-
.to.eql(values)
|
1608
|
-
})
|
1609
|
-
|
1610
|
-
it('transforms `array` type schemas without `enum` (`items` is an object of `array` type and `items` is an object of `string` type)', () => {
|
1611
|
-
const document = [['string']]
|
1612
|
-
|
1613
|
-
const schema = {
|
1614
|
-
type: 'array',
|
1615
|
-
items: {
|
1616
|
-
type: 'array',
|
1617
|
-
items: {
|
1618
|
-
type: 'string'
|
1619
|
-
}
|
1620
|
-
}
|
1621
|
-
}
|
1622
|
-
|
1623
|
-
const values = {
|
1624
|
-
'#/0/0': 'string'
|
1625
|
-
}
|
1626
|
-
|
1627
|
-
return expect(transform(document, schema))
|
1628
|
-
.to.eql(values)
|
1629
|
-
})
|
1630
|
-
|
1631
|
-
it('transforms `array` type schemas without `enum` (`items` is an object of `array` type and `items` is an object of `number` type)', () => {
|
1632
|
-
const document = [[1]]
|
1633
|
-
|
1634
|
-
const schema = {
|
1635
|
-
type: 'array',
|
1636
|
-
items: {
|
1637
|
-
type: 'array',
|
1638
|
-
items: {
|
1639
|
-
type: 'number'
|
1640
|
-
}
|
1641
|
-
}
|
1642
|
-
}
|
1643
|
-
|
1644
|
-
const values = {
|
1645
|
-
'#/0/0': '1'
|
1646
|
-
}
|
1647
|
-
|
1648
|
-
return expect(transform(document, schema))
|
1649
|
-
.to.eql(values)
|
1650
|
-
})
|
1651
|
-
|
1652
|
-
it('transforms `array` type schemas without `enum` (`items` is an object of `array` type and `items` is an object of `boolean` type)', () => {
|
1653
|
-
const document = [[false]]
|
1654
|
-
|
1655
|
-
const schema = {
|
1656
|
-
type: 'array',
|
1657
|
-
items: {
|
1658
|
-
type: 'array',
|
1659
|
-
items: {
|
1660
|
-
type: 'boolean'
|
1661
|
-
}
|
1662
|
-
}
|
1663
|
-
}
|
1664
|
-
|
1665
|
-
const values = {
|
1666
|
-
'#/0/0': 'false'
|
1667
|
-
}
|
1668
|
-
|
1669
|
-
return expect(transform(document, schema))
|
1670
|
-
.to.eql(values)
|
1671
|
-
})
|
1672
|
-
|
1673
|
-
it('transforms `array` type schemas without `enum` (`items` is an object of `array` type and `items` is an object of `null` type)', () => {
|
1674
|
-
const document = [[null]]
|
1675
|
-
|
1676
|
-
const schema = {
|
1677
|
-
type: 'array',
|
1678
|
-
items: {
|
1679
|
-
type: 'array',
|
1680
|
-
items: {
|
1681
|
-
type: 'null'
|
1682
|
-
}
|
1683
|
-
}
|
1684
|
-
}
|
1685
|
-
|
1686
|
-
const values = {
|
1687
|
-
'#/0/0': 'null'
|
1688
|
-
}
|
1689
|
-
|
1690
|
-
return expect(transform(document, schema))
|
1691
|
-
.to.eql(values)
|
1692
|
-
})
|
1693
|
-
|
1694
|
-
it('transforms `array` type schemas without `enum` (`items` is an object of `object` type)', () => {
|
1695
|
-
const document = [
|
1696
|
-
{
|
1697
|
-
one: 'mock array type index object type key string',
|
1698
|
-
two: '1'
|
1699
|
-
}
|
1700
|
-
]
|
1701
|
-
|
1702
|
-
const schema = {
|
1703
|
-
type: 'array',
|
1704
|
-
items: {
|
1705
|
-
type: 'object',
|
1706
|
-
properties: {
|
1707
|
-
one: {
|
1708
|
-
type: 'string'
|
1709
|
-
},
|
1710
|
-
two: {
|
1711
|
-
type: 'number'
|
1712
|
-
}
|
1713
|
-
}
|
1714
|
-
}
|
1715
|
-
}
|
1716
|
-
|
1717
|
-
const values = {
|
1718
|
-
'#/0/one': 'mock array type index object type key string',
|
1719
|
-
'#/0/two': '1'
|
1720
|
-
}
|
1721
|
-
|
1722
|
-
return expect(transform(document, schema))
|
1723
|
-
.to.eql(values)
|
1724
|
-
})
|
1725
|
-
|
1726
|
-
it('transforms `array` type schemas without `enum` (`items` is an object of `boolean` type)', () => {
|
1727
|
-
const document = [true]
|
1728
|
-
|
1729
|
-
const schema = {
|
1730
|
-
type: 'array',
|
1731
|
-
items: {
|
1732
|
-
type: 'boolean'
|
1733
|
-
}
|
1734
|
-
}
|
1735
|
-
|
1736
|
-
const values = {
|
1737
|
-
'#/0': 'true'
|
1738
|
-
}
|
1739
|
-
|
1740
|
-
return expect(transform(document, schema))
|
1741
|
-
.to.eql(values)
|
1742
|
-
})
|
1743
|
-
|
1744
|
-
it('transforms `array` type schemas without `enum` (`items` is an object of `null` type)', () => {
|
1745
|
-
const document = [null]
|
1746
|
-
|
1747
|
-
const schema = {
|
1748
|
-
type: 'array',
|
1749
|
-
items: {
|
1750
|
-
type: 'null'
|
1751
|
-
}
|
1752
|
-
}
|
1753
|
-
|
1754
|
-
const values = {
|
1755
|
-
'#/0': 'null'
|
1756
|
-
}
|
1757
|
-
|
1758
|
-
return expect(transform(document, schema))
|
1759
|
-
.to.eql(values)
|
1760
|
-
})
|
1761
|
-
})
|
1762
|
-
|
1763
|
-
describe('Transforming `object` type schemas', () => {
|
1764
|
-
it('transforms `object` type schemas with `enum`', () => {
|
1765
|
-
const document = {
|
1766
|
-
one: 'mock object type key string (1)',
|
1767
|
-
two: 'mock object type key string (2)'
|
1768
|
-
}
|
1769
|
-
|
1770
|
-
const schema = {
|
1771
|
-
type: 'object',
|
1772
|
-
properties: {
|
1773
|
-
one: { type: 'string', enum: ['mock object type key string (1)', 'mock object type key string (2)'] },
|
1774
|
-
two: { type: 'string', enum: ['mock object type key string (1)', 'mock object type key string (2)'] }
|
1775
|
-
}
|
1776
|
-
}
|
1777
|
-
|
1778
|
-
const values = {
|
1779
|
-
'#/one': '0',
|
1780
|
-
'#/two': '1'
|
1781
|
-
}
|
1782
|
-
|
1783
|
-
return expect(transform(document, schema))
|
1784
|
-
.to.eql(values)
|
1785
|
-
})
|
1786
|
-
|
1787
|
-
it('transforms `object` type schemas without `enum`', () => {
|
1788
|
-
const document = {
|
1789
|
-
one: 'mock object type key string (1)',
|
1790
|
-
two: 'mock object type key string (2)'
|
1791
|
-
}
|
1792
|
-
|
1793
|
-
const schema = {
|
1794
|
-
type: 'object',
|
1795
|
-
properties: {
|
1796
|
-
one: { type: 'string' },
|
1797
|
-
two: { type: 'string' }
|
1798
|
-
}
|
1799
|
-
}
|
1800
|
-
|
1801
|
-
const values = {
|
1802
|
-
'#/one': 'mock object type key string (1)',
|
1803
|
-
'#/two': 'mock object type key string (2)'
|
1804
|
-
}
|
1805
|
-
|
1806
|
-
return expect(transform(document, schema))
|
1807
|
-
.to.eql(values)
|
1808
|
-
})
|
1809
|
-
})
|
1810
|
-
|
1811
|
-
describe('Transforming `boolean` type schemas', () => {
|
1812
|
-
it('transforms `boolean` type schemas with `enum`', () => {
|
1813
|
-
const document = false
|
1814
|
-
|
1815
|
-
const schema = { type: 'boolean', enum: [true, false] }
|
1816
|
-
|
1817
|
-
const values = {
|
1818
|
-
'#/': '1'
|
1819
|
-
}
|
1820
|
-
|
1821
|
-
return expect(transform(document, schema))
|
1822
|
-
.to.eql(values)
|
1823
|
-
})
|
1824
|
-
|
1825
|
-
it('transforms `boolean` type schemas without `enum`', () => {
|
1826
|
-
const document = true
|
1827
|
-
|
1828
|
-
const schema = { type: 'boolean' }
|
1829
|
-
|
1830
|
-
const values = {
|
1831
|
-
'#/': 'true'
|
1832
|
-
}
|
1833
|
-
|
1834
|
-
return expect(transform(document, schema))
|
1835
|
-
.to.eql(values)
|
1836
|
-
})
|
1837
|
-
})
|
1838
|
-
|
1839
|
-
describe('Transforming `null` type schemas', () => {
|
1840
|
-
it('transforms `null` type schemas with `enum`', () => {
|
1841
|
-
const document = null
|
1842
|
-
|
1843
|
-
const schema = { type: 'null', enum: [null] }
|
1844
|
-
|
1845
|
-
const values = {
|
1846
|
-
'#/': '0'
|
1847
|
-
}
|
1848
|
-
|
1849
|
-
return expect(transform(document, schema))
|
1850
|
-
.to.eql(values)
|
1851
|
-
})
|
1852
|
-
|
1853
|
-
it('transforms `null` type schemas without `enum`', () => {
|
1854
|
-
const document = null
|
1855
|
-
|
1856
|
-
const schema = { type: 'null' }
|
1857
|
-
|
1858
|
-
const values = {
|
1859
|
-
'#/': 'null'
|
1860
|
-
}
|
1861
|
-
|
1862
|
-
return expect(transform(document, schema))
|
1863
|
-
.to.eql(values)
|
1864
|
-
})
|
1865
|
-
})
|
1866
|
-
})
|