@@ -55,26 +55,16 @@ test('object with allOf and multiple schema on the allOf', (t) => {
5555 t . is ( e . message , '"id" is required!' )
5656 }
5757
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}' )
6762
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}' )
7868} )
7969
8070test ( '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) => {
9989 }
10090 const stringify = build ( schema )
10191
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}' )
11096} )
11197
11298test ( 'object with allOf and no schema on the allOf' , ( t ) => {
@@ -167,22 +153,14 @@ test('object with nested allOfs', (t) => {
167153 ]
168154 }
169155
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}' )
186164} )
187165
188166test ( 'object with $ref in allOf' , ( t ) => {
@@ -208,20 +186,12 @@ test('object with $ref in allOf', (t) => {
208186 ]
209187 }
210188
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}' )
225195} )
226196
227197test ( 'object with $ref and other object in allOf' , ( t ) => {
@@ -255,21 +225,13 @@ test('object with $ref and other object in allOf', (t) => {
255225 ]
256226 }
257227
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}' )
273235} )
274236
275237test ( 'object with multiple $refs in allOf' , ( t ) => {
@@ -306,21 +268,13 @@ test('object with multiple $refs in allOf', (t) => {
306268 ]
307269 }
308270
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}' )
324278} )
325279
326280test ( 'object with external $refs in allOf' , ( t ) => {
@@ -365,19 +319,11 @@ test('object with external $refs in allOf', (t) => {
365319 ]
366320 }
367321
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}' )
383329} )
0 commit comments