11'use strict'
22
3- const { test } = require ( 'tap ' )
3+ const { test } = require ( 'node:test ' )
44const clone = require ( 'rfdc' ) ( { proto : true , circles : false } )
55
66const RefResolver = require ( '../ref-resolver' )
@@ -13,8 +13,8 @@ const save = (out) => require('fs').writeFileSync(`./out-${Date.now()}.json`, JS
1313
1414test ( 'wrong params' , t => {
1515 t . plan ( 2 )
16- t . throws ( ( ) => RefResolver ( { target : 'draft-1000' } ) )
17- t . throws ( ( ) => RefResolver ( { externalSchemas : [ ] } ) , 'need application uri' )
16+ t . assert . throws ( ( ) => RefResolver ( { target : 'draft-1000' } ) )
17+ t . assert . throws ( ( ) => RefResolver ( { externalSchemas : [ ] } ) , 'need application uri' )
1818} )
1919
2020test ( '$ref to root' , t => {
@@ -31,8 +31,8 @@ test('$ref to root', t => {
3131
3232 const originalSchema = clone ( schema )
3333 const out = resolver . resolve ( schema , opts )
34- t . same ( schema , originalSchema , 'the param schema should not be changed' )
35- t . equal ( schema , out , 'the output schema is the same (LINK) of the input one' )
34+ t . assert . deepStrictEqual ( schema , originalSchema , 'the param schema should not be changed' )
35+ t . assert . strictEqual ( schema , out , 'the output schema is the same (LINK) of the input one' )
3636} )
3737
3838test ( '$ref to an external schema' , t => {
@@ -48,9 +48,9 @@ test('$ref to an external schema', t => {
4848 const resolver = RefResolver ( )
4949
5050 const out = resolver . resolve ( schema , opts )
51- t . same ( schema , out , 'the output is the same input - modified' )
52- t . ok ( out . definitions , 'definitions has been added' )
53- t . same ( Object . values ( out . definitions ) , opts . externalSchemas , 'external schema has been added to definitions' )
51+ t . assert . deepStrictEqual ( schema , out , 'the output is the same input - modified' )
52+ t . assert . ok ( out . definitions , 'definitions has been added' )
53+ t . assert . deepStrictEqual ( Object . values ( out . definitions ) , opts . externalSchemas , 'external schema has been added to definitions' )
5454} )
5555
5656test ( '$ref to an external schema without changes' , t => {
@@ -67,10 +67,10 @@ test('$ref to an external schema without changes', t => {
6767
6868 const originalSchema = clone ( schema )
6969 const out = resolver . resolve ( schema , opts )
70- t . same ( schema , originalSchema , 'the input is unchanged' )
71- t . notMatch ( schema , out , 'the input is unchanged' )
72- t . ok ( out . definitions , 'definitions has been added' )
73- t . same ( Object . values ( out . definitions ) , opts . externalSchemas , 'external schema has been added to definitions' )
70+ t . assert . deepStrictEqual ( schema , originalSchema , 'the input is unchanged' )
71+ t . assert . notDeepStrictEqual ( schema , out , 'the input is unchanged' )
72+ t . assert . ok ( out . definitions , 'definitions has been added' )
73+ t . assert . deepStrictEqual ( Object . values ( out . definitions ) , opts . externalSchemas , 'external schema has been added to definitions' )
7474} )
7575
7676test ( '$ref circular' , t => {
@@ -89,9 +89,9 @@ test('$ref circular', t => {
8989
9090 const resolver = RefResolver ( )
9191 const out = resolver . resolve ( schema , opts )
92- t . same ( schema , out , 'the output is the same input modified' )
93- t . ok ( out . definitions , 'definitions has been added' )
94- t . same ( Object . values ( out . definitions ) , opts . externalSchemas , 'external schema has been added to definitions' )
92+ t . assert . deepStrictEqual ( schema , out , 'the output is the same input modified' )
93+ t . assert . ok ( out . definitions , 'definitions has been added' )
94+ t . assert . deepStrictEqual ( Object . values ( out . definitions ) , opts . externalSchemas , 'external schema has been added to definitions' )
9595} )
9696
9797test ( '$ref circular' , t => {
@@ -110,9 +110,9 @@ test('$ref circular', t => {
110110
111111 const resolver = RefResolver ( )
112112 const out = resolver . resolve ( schema , opts )
113- t . same ( schema , out , 'the output is the same input modified' )
114- t . ok ( out . definitions , 'definitions has been added' )
115- t . same ( Object . values ( out . definitions ) , [ opts . externalSchemas [ 1 ] ] , 'only used schema are added' )
113+ t . assert . deepStrictEqual ( schema , out , 'the output is the same input modified' )
114+ t . assert . ok ( out . definitions , 'definitions has been added' )
115+ t . assert . deepStrictEqual ( Object . values ( out . definitions ) , [ opts . externalSchemas [ 1 ] ] , 'only used schema are added' )
116116} )
117117
118118test ( '$ref local ids' , { skip : true } , t => {
@@ -128,9 +128,9 @@ test('$ref local ids', { skip: true }, t => {
128128
129129 const resolver = RefResolver ( )
130130 const out = resolver . resolve ( schema , opts )
131- t . same ( schema , out , 'the output is the same input modified' )
131+ t . assert . deepStrictEqual ( schema , out , 'the output is the same input modified' )
132132 // TODO build a graph to track is an external schema is referenced by the root
133- t . equal ( Object . values ( out . definitions ) . length , 1 , 'no external schema added' )
133+ t . assert . strictEqual ( Object . values ( out . definitions ) . length , 1 , 'no external schema added' )
134134} )
135135
136136test ( 'skip duplicated ids' , t => {
@@ -145,8 +145,8 @@ test('skip duplicated ids', t => {
145145
146146 const resolver = RefResolver ( )
147147 const out = resolver . resolve ( schema , opts )
148- t . same ( schema , out , 'the output is the same input modified' )
149- t . equal ( Object . values ( out . definitions ) . length , 1 , 'no external schema added' )
148+ t . assert . deepStrictEqual ( schema , out , 'the output is the same input modified' )
149+ t . assert . strictEqual ( Object . values ( out . definitions ) . length , 1 , 'no external schema added' )
150150} )
151151
152152test ( 'dont resolve external schema missing' , t => {
@@ -155,7 +155,7 @@ test('dont resolve external schema missing', t => {
155155
156156 const resolver = RefResolver ( { clone : true } )
157157 const out = resolver . resolve ( schema )
158- t . same ( schema , out , 'the output is the same input not modified' )
158+ t . assert . deepStrictEqual ( schema , out , 'the output is the same input not modified' )
159159} )
160160
161161test ( 'dont resolve external schema missing #2' , t => {
@@ -164,7 +164,7 @@ test('dont resolve external schema missing #2', t => {
164164
165165 const resolver = RefResolver ( { clone : true } )
166166 const out = resolver . resolve ( schema )
167- t . same ( schema , out , 'the output is the same input not modified' )
167+ t . assert . deepStrictEqual ( schema , out , 'the output is the same input not modified' )
168168} )
169169
170170test ( 'missing id in root schema' , t => {
@@ -182,9 +182,9 @@ test('missing id in root schema', t => {
182182
183183 const resolver = RefResolver ( )
184184 const out = resolver . resolve ( schema , opts )
185- t . same ( schema , out , 'the output is the same input modified' )
186- t . ok ( out . definitions , 'definitions has been added' )
187- t . same ( Object . values ( out . definitions ) , opts . externalSchemas , 'external schema has been added to definitions' )
185+ t . assert . deepStrictEqual ( schema , out , 'the output is the same input modified' )
186+ t . assert . ok ( out . definitions , 'definitions has been added' )
187+ t . assert . deepStrictEqual ( Object . values ( out . definitions ) , opts . externalSchemas , 'external schema has been added to definitions' )
188188} )
189189
190190test ( 'absolute $ref' , t => {
@@ -214,8 +214,8 @@ test('absolute $ref', t => {
214214 const resolver = RefResolver ( { clone : true , applicationUri : 'todo.com' , externalSchemas } )
215215 const out = resolver . resolve ( schema )
216216
217- t . not ( out . $ref , 'http://example.com/#/definitions/idParam' )
218- t . same ( resolver . definitions ( ) , {
217+ t . assert . notEqual ( out . $ref , 'http://example.com/#/definitions/idParam' )
218+ t . assert . deepStrictEqual ( resolver . definitions ( ) , {
219219 definitions : {
220220 'def-0' : absSchemaId
221221 }
@@ -241,6 +241,6 @@ test('absolute $ref #2', t => {
241241
242242 const resolver = RefResolver ( { clone : true } )
243243 const out = resolver . resolve ( schema , { externalSchemas } )
244- t . equal ( out . properties . address . $ref , '#/definitions/def-0' )
245- t . equal ( out . properties . houses . items . $ref , '#/definitions/def-0' )
244+ t . assert . strictEqual ( out . properties . address . $ref , '#/definitions/def-0' )
245+ t . assert . strictEqual ( out . properties . houses . items . $ref , '#/definitions/def-0' )
246246} )
0 commit comments