1
1
'use strict'
2
2
3
- const test = require ( 'tap' ) . test
3
+ const { test } = require ( 'node:test' )
4
4
const build = require ( '..' )
5
5
6
6
test ( 'additionalProperties' , ( t ) => {
@@ -19,7 +19,7 @@ test('additionalProperties', (t) => {
19
19
} )
20
20
21
21
const obj = { str : 'test' , foo : 42 , ofoo : true , foof : 'string' , objfoo : { a : true } }
22
- t . equal ( stringify ( obj ) , '{"str":"test","foo":"42","ofoo":"true","foof":"string","objfoo":"[object Object]"}' )
22
+ t . assert . equal ( stringify ( obj ) , '{"str":"test","foo":"42","ofoo":"true","foof":"string","objfoo":"[object Object]"}' )
23
23
} )
24
24
25
25
test ( 'additionalProperties should not change properties' , ( t ) => {
@@ -38,7 +38,7 @@ test('additionalProperties should not change properties', (t) => {
38
38
} )
39
39
40
40
const obj = { foo : '42' , ofoo : 42 }
41
- t . equal ( stringify ( obj ) , '{"foo":"42","ofoo":42}' )
41
+ t . assert . equal ( stringify ( obj ) , '{"foo":"42","ofoo":42}' )
42
42
} )
43
43
44
44
test ( 'additionalProperties should not change properties and patternProperties' , ( t ) => {
@@ -62,7 +62,7 @@ test('additionalProperties should not change properties and patternProperties',
62
62
} )
63
63
64
64
const obj = { foo : '42' , ofoo : 42 , test : '42' }
65
- t . equal ( stringify ( obj ) , '{"foo":"42","ofoo":"42","test":42}' )
65
+ t . assert . equal ( stringify ( obj ) , '{"foo":"42","ofoo":"42","test":42}' )
66
66
} )
67
67
68
68
test ( 'additionalProperties set to true, use of fast-safe-stringify' , ( t ) => {
@@ -75,7 +75,7 @@ test('additionalProperties set to true, use of fast-safe-stringify', (t) => {
75
75
} )
76
76
77
77
const obj = { foo : true , ofoo : 42 , arrfoo : [ 'array' , 'test' ] , objfoo : { a : 'world' } }
78
- t . equal ( stringify ( obj ) , '{"foo":true,"ofoo":42,"arrfoo":["array","test"],"objfoo":{"a":"world"}}' )
78
+ t . assert . equal ( stringify ( obj ) , '{"foo":true,"ofoo":42,"arrfoo":["array","test"],"objfoo":{"a":"world"}}' )
79
79
} )
80
80
81
81
test ( 'additionalProperties - string coerce' , ( t ) => {
@@ -90,7 +90,7 @@ test('additionalProperties - string coerce', (t) => {
90
90
} )
91
91
92
92
const obj = { foo : true , ofoo : 42 , arrfoo : [ 'array' , 'test' ] , objfoo : { a : 'world' } }
93
- t . equal ( stringify ( obj ) , '{"foo":"true","ofoo":"42","arrfoo":"array,test","objfoo":"[object Object]"}' )
93
+ t . assert . equal ( stringify ( obj ) , '{"foo":"true","ofoo":"42","arrfoo":"array,test","objfoo":"[object Object]"}' )
94
94
} )
95
95
96
96
test ( 'additionalProperties - number skip' , ( t ) => {
@@ -106,7 +106,7 @@ test('additionalProperties - number skip', (t) => {
106
106
107
107
// const obj = { foo: true, ofoo: '42', xfoo: 'string', arrfoo: [1, 2], objfoo: { num: 42 } }
108
108
const obj = { foo : true , ofoo : '42' }
109
- t . equal ( stringify ( obj ) , '{"foo":1,"ofoo":42}' )
109
+ t . assert . equal ( stringify ( obj ) , '{"foo":1,"ofoo":42}' )
110
110
} )
111
111
112
112
test ( 'additionalProperties - boolean coerce' , ( t ) => {
@@ -121,7 +121,7 @@ test('additionalProperties - boolean coerce', (t) => {
121
121
} )
122
122
123
123
const obj = { foo : 'true' , ofoo : 0 , arrfoo : [ 1 , 2 ] , objfoo : { a : true } }
124
- t . equal ( stringify ( obj ) , '{"foo":true,"ofoo":false,"arrfoo":true,"objfoo":true}' )
124
+ t . assert . equal ( stringify ( obj ) , '{"foo":true,"ofoo":false,"arrfoo":true,"objfoo":true}' )
125
125
} )
126
126
127
127
test ( 'additionalProperties - object coerce' , ( t ) => {
@@ -141,7 +141,7 @@ test('additionalProperties - object coerce', (t) => {
141
141
} )
142
142
143
143
const obj = { objfoo : { answer : 42 } }
144
- t . equal ( stringify ( obj ) , '{"objfoo":{"answer":42}}' )
144
+ t . assert . equal ( stringify ( obj ) , '{"objfoo":{"answer":42}}' )
145
145
} )
146
146
147
147
test ( 'additionalProperties - array coerce' , ( t ) => {
@@ -159,10 +159,10 @@ test('additionalProperties - array coerce', (t) => {
159
159
} )
160
160
161
161
const coercibleValues = { arrfoo : [ 1 , 2 ] }
162
- t . equal ( stringify ( coercibleValues ) , '{"arrfoo":["1","2"]}' )
162
+ t . assert . equal ( stringify ( coercibleValues ) , '{"arrfoo":["1","2"]}' )
163
163
164
164
const incoercibleValues = { foo : 'true' , ofoo : 0 , objfoo : { tyrion : 'lannister' } }
165
- t . throws ( ( ) => stringify ( incoercibleValues ) )
165
+ t . assert . throws ( ( ) => stringify ( incoercibleValues ) )
166
166
} )
167
167
168
168
test ( 'additionalProperties with empty schema' , ( t ) => {
@@ -173,7 +173,7 @@ test('additionalProperties with empty schema', (t) => {
173
173
} )
174
174
175
175
const obj = { a : 1 , b : true , c : null }
176
- t . equal ( stringify ( obj ) , '{"a":1,"b":true,"c":null}' )
176
+ t . assert . equal ( stringify ( obj ) , '{"a":1,"b":true,"c":null}' )
177
177
} )
178
178
179
179
test ( 'additionalProperties with nested empty schema' , ( t ) => {
@@ -187,7 +187,7 @@ test('additionalProperties with nested empty schema', (t) => {
187
187
} )
188
188
189
189
const obj = { data : { a : 1 , b : true , c : null } }
190
- t . equal ( stringify ( obj ) , '{"data":{"a":1,"b":true,"c":null}}' )
190
+ t . assert . equal ( stringify ( obj ) , '{"data":{"a":1,"b":true,"c":null}}' )
191
191
} )
192
192
193
193
test ( 'nested additionalProperties' , ( t ) => {
@@ -207,7 +207,7 @@ test('nested additionalProperties', (t) => {
207
207
} )
208
208
209
209
const obj = [ { ap : { value : 'string' } } ]
210
- t . equal ( stringify ( obj ) , '[{"ap":{"value":"string"}}]' )
210
+ t . assert . equal ( stringify ( obj ) , '[{"ap":{"value":"string"}}]' )
211
211
} )
212
212
213
213
test ( 'very nested additionalProperties' , ( t ) => {
@@ -244,7 +244,7 @@ test('very nested additionalProperties', (t) => {
244
244
} )
245
245
246
246
const obj = [ { ap : { nested : { moarNested : { finally : { value : 'str' } } } } } ]
247
- t . equal ( stringify ( obj ) , '[{"ap":{"nested":{"moarNested":{"finally":{"value":"str"}}}}}]' )
247
+ t . assert . equal ( stringify ( obj ) , '[{"ap":{"nested":{"moarNested":{"finally":{"value":"str"}}}}}]' )
248
248
} )
249
249
250
250
test ( 'nested additionalProperties set to true' , ( t ) => {
@@ -261,7 +261,7 @@ test('nested additionalProperties set to true', (t) => {
261
261
} )
262
262
263
263
const obj = { ap : { value : 'string' , someNumber : 42 } }
264
- t . equal ( stringify ( obj ) , '{"ap":{"value":"string","someNumber":42}}' )
264
+ t . assert . equal ( stringify ( obj ) , '{"ap":{"value":"string","someNumber":42}}' )
265
265
} )
266
266
267
267
test ( 'field passed to fastSafeStringify as undefined should be removed' , ( t ) => {
@@ -278,7 +278,7 @@ test('field passed to fastSafeStringify as undefined should be removed', (t) =>
278
278
} )
279
279
280
280
const obj = { ap : { value : 'string' , someNumber : undefined } }
281
- t . equal ( stringify ( obj ) , '{"ap":{"value":"string"}}' )
281
+ t . assert . equal ( stringify ( obj ) , '{"ap":{"value":"string"}}' )
282
282
} )
283
283
284
284
test ( 'property without type but with enum, will acts as additionalProperties' , ( t ) => {
@@ -294,7 +294,7 @@ test('property without type but with enum, will acts as additionalProperties', (
294
294
} )
295
295
296
296
const obj = { ap : { additional : 'field' } }
297
- t . equal ( stringify ( obj ) , '{"ap":{"additional":"field"}}' )
297
+ t . assert . equal ( stringify ( obj ) , '{"ap":{"additional":"field"}}' )
298
298
} )
299
299
300
300
test ( 'property without type but with enum, will acts as additionalProperties without overwriting' , ( t ) => {
@@ -311,7 +311,7 @@ test('property without type but with enum, will acts as additionalProperties wit
311
311
} )
312
312
313
313
const obj = { ap : { additional : 'field' } }
314
- t . equal ( stringify ( obj ) , '{"ap":{}}' )
314
+ t . assert . equal ( stringify ( obj ) , '{"ap":{}}' )
315
315
} )
316
316
317
317
test ( 'function and symbol references are not serialized as undefined' , ( t ) => {
@@ -328,5 +328,5 @@ test('function and symbol references are not serialized as undefined', (t) => {
328
328
} )
329
329
330
330
const obj = { str : 'x' , test : 'test' , meth : ( ) => 'x' , sym : Symbol ( 'x' ) }
331
- t . equal ( stringify ( obj ) , '{"str":"x","test":"test"}' )
331
+ t . assert . equal ( stringify ( obj ) , '{"str":"x","test":"test"}' )
332
332
} )
0 commit comments