@@ -55,26 +55,16 @@ test('object with allOf and multiple schema on the allOf', (t) => {
55
55
t . is ( e . message , '"id" is required!' )
56
56
}
57
57
58
- try {
59
- const value = stringify ( {
60
- id : 1 ,
61
- name : 'string'
62
- } )
63
- t . is ( value , '{"name":"string","id":1}' )
64
- } catch ( e ) {
65
- t . fail ( )
66
- }
58
+ t . is ( stringify ( {
59
+ id : 1 ,
60
+ name : 'string'
61
+ } ) , '{"name":"string","id":1}' )
67
62
68
- try {
69
- const value = stringify ( {
70
- id : 1 ,
71
- name : 'string' ,
72
- tag : 'otherString'
73
- } )
74
- t . is ( value , '{"name":"string","tag":"otherString","id":1}' )
75
- } catch ( e ) {
76
- t . fail ( )
77
- }
63
+ t . is ( stringify ( {
64
+ id : 1 ,
65
+ name : 'string' ,
66
+ tag : 'otherString'
67
+ } ) , '{"name":"string","tag":"otherString","id":1}' )
78
68
} )
79
69
80
70
test ( 'object with allOf and one schema on the allOf' , ( t ) => {
@@ -99,14 +89,10 @@ test('object with allOf and one schema on the allOf', (t) => {
99
89
}
100
90
const stringify = build ( schema )
101
91
102
- try {
103
- const value = stringify ( {
104
- id : 1
105
- } )
106
- t . is ( value , '{"id":1}' )
107
- } catch ( e ) {
108
- t . fail ( )
109
- }
92
+ const value = stringify ( {
93
+ id : 1
94
+ } )
95
+ t . is ( value , '{"id":1}' )
110
96
} )
111
97
112
98
test ( 'object with allOf and no schema on the allOf' , ( t ) => {
@@ -167,22 +153,14 @@ test('object with nested allOfs', (t) => {
167
153
]
168
154
}
169
155
170
- try {
171
- const stringify = build ( schema )
172
- try {
173
- const value = stringify ( {
174
- id1 : 1 ,
175
- id2 : 2 ,
176
- id3 : 3 ,
177
- id4 : 4 // extra prop shouldn't be in result
178
- } )
179
- t . is ( value , '{"id1":1,"id2":2,"id3":3}' )
180
- } catch ( e ) {
181
- t . fail ( )
182
- }
183
- } catch ( e ) {
184
- t . fail ( )
185
- }
156
+ const stringify = build ( schema )
157
+ const value = stringify ( {
158
+ id1 : 1 ,
159
+ id2 : 2 ,
160
+ id3 : 3 ,
161
+ id4 : 4 // extra prop shouldn't be in result
162
+ } )
163
+ t . is ( value , '{"id1":1,"id2":2,"id3":3}' )
186
164
} )
187
165
188
166
test ( 'object with $ref in allOf' , ( t ) => {
@@ -208,20 +186,12 @@ test('object with $ref in allOf', (t) => {
208
186
]
209
187
}
210
188
211
- try {
212
- const stringify = build ( schema )
213
- try {
214
- const value = stringify ( {
215
- id1 : 1 ,
216
- id2 : 2 // extra prop shouldn't be in result
217
- } )
218
- t . is ( value , '{"id1":1}' )
219
- } catch ( e ) {
220
- t . fail ( )
221
- }
222
- } catch ( e ) {
223
- t . fail ( )
224
- }
189
+ const stringify = build ( schema )
190
+ const value = stringify ( {
191
+ id1 : 1 ,
192
+ id2 : 2 // extra prop shouldn't be in result
193
+ } )
194
+ t . is ( value , '{"id1":1}' )
225
195
} )
226
196
227
197
test ( 'object with $ref and other object in allOf' , ( t ) => {
@@ -255,21 +225,13 @@ test('object with $ref and other object in allOf', (t) => {
255
225
]
256
226
}
257
227
258
- try {
259
- const stringify = build ( schema )
260
- try {
261
- const value = stringify ( {
262
- id1 : 1 ,
263
- id2 : 2 ,
264
- id3 : 3 // extra prop shouldn't be in result
265
- } )
266
- t . is ( value , '{"id1":1,"id2":2}' )
267
- } catch ( e ) {
268
- t . fail ( )
269
- }
270
- } catch ( e ) {
271
- t . fail ( )
272
- }
228
+ const stringify = build ( schema )
229
+ const value = stringify ( {
230
+ id1 : 1 ,
231
+ id2 : 2 ,
232
+ id3 : 3 // extra prop shouldn't be in result
233
+ } )
234
+ t . is ( value , '{"id1":1,"id2":2}' )
273
235
} )
274
236
275
237
test ( 'object with multiple $refs in allOf' , ( t ) => {
@@ -306,21 +268,13 @@ test('object with multiple $refs in allOf', (t) => {
306
268
]
307
269
}
308
270
309
- try {
310
- const stringify = build ( schema )
311
- try {
312
- const value = stringify ( {
313
- id1 : 1 ,
314
- id2 : 2 ,
315
- id3 : 3 // extra prop shouldn't be in result
316
- } )
317
- t . is ( value , '{"id1":1,"id2":2}' )
318
- } catch ( e ) {
319
- t . fail ( )
320
- }
321
- } catch ( e ) {
322
- t . fail ( )
323
- }
271
+ const stringify = build ( schema )
272
+ const value = stringify ( {
273
+ id1 : 1 ,
274
+ id2 : 2 ,
275
+ id3 : 3 // extra prop shouldn't be in result
276
+ } )
277
+ t . is ( value , '{"id1":1,"id2":2}' )
324
278
} )
325
279
326
280
test ( 'object with external $refs in allOf' , ( t ) => {
@@ -365,19 +319,11 @@ test('object with external $refs in allOf', (t) => {
365
319
]
366
320
}
367
321
368
- try {
369
- const stringify = build ( schema , { schema : externalSchema } )
370
- try {
371
- const value = stringify ( {
372
- id1 : 1 ,
373
- id2 : 2 ,
374
- id3 : 3 // extra prop shouldn't be in result
375
- } )
376
- t . is ( value , '{"id1":1,"id2":2}' )
377
- } catch ( e ) {
378
- t . fail ( )
379
- }
380
- } catch ( e ) {
381
- t . fail ( )
382
- }
322
+ const stringify = build ( schema , { schema : externalSchema } )
323
+ const value = stringify ( {
324
+ id1 : 1 ,
325
+ id2 : 2 ,
326
+ id3 : 3 // extra prop shouldn't be in result
327
+ } )
328
+ t . is ( value , '{"id1":1,"id2":2}' )
383
329
} )
0 commit comments