Skip to content

Commit 517a7bf

Browse files
authored
chore(test): converted all the tap tests with node:test (#739)
1 parent 665d0b2 commit 517a7bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+912
-1060
lines changed

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,3 @@ yarn.lock
147147
# editor files
148148
.vscode
149149
.idea
150-
151-
#tap files
152-
.tap/

.taprc

-7
This file was deleted.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"lint": "standard",
1414
"lint:fix": "standard --fix",
1515
"test:typescript": "tsd",
16-
"test:unit": "tap",
16+
"test:unit": "c8 node --test",
1717
"test": "npm run test:unit && npm run test:typescript"
1818
},
1919
"precommit": [
@@ -40,13 +40,13 @@
4040
"@fastify/pre-commit": "^2.1.0",
4141
"@sinclair/typebox": "^0.33.4",
4242
"benchmark": "^2.1.4",
43+
"c8": "^10.1.2",
4344
"cli-select": "^1.1.2",
4445
"compile-json-stringify": "^0.1.2",
4546
"fast-json-stringify": ".",
4647
"is-my-json-valid": "^2.20.6",
4748
"simple-git": "^3.23.0",
4849
"standard": "^17.1.0",
49-
"tap": "^19.2.5",
5050
"tsd": "^0.31.0",
5151
"webpack": "^5.90.3"
5252
},

test/additionalProperties.test.js

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const test = require('tap').test
3+
const { test } = require('node:test')
44
const build = require('..')
55

66
test('additionalProperties', (t) => {
@@ -19,7 +19,7 @@ test('additionalProperties', (t) => {
1919
})
2020

2121
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]"}')
2323
})
2424

2525
test('additionalProperties should not change properties', (t) => {
@@ -38,7 +38,7 @@ test('additionalProperties should not change properties', (t) => {
3838
})
3939

4040
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}')
4242
})
4343

4444
test('additionalProperties should not change properties and patternProperties', (t) => {
@@ -62,7 +62,7 @@ test('additionalProperties should not change properties and patternProperties',
6262
})
6363

6464
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}')
6666
})
6767

6868
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) => {
7575
})
7676

7777
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"}}')
7979
})
8080

8181
test('additionalProperties - string coerce', (t) => {
@@ -90,7 +90,7 @@ test('additionalProperties - string coerce', (t) => {
9090
})
9191

9292
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]"}')
9494
})
9595

9696
test('additionalProperties - number skip', (t) => {
@@ -106,7 +106,7 @@ test('additionalProperties - number skip', (t) => {
106106

107107
// const obj = { foo: true, ofoo: '42', xfoo: 'string', arrfoo: [1, 2], objfoo: { num: 42 } }
108108
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}')
110110
})
111111

112112
test('additionalProperties - boolean coerce', (t) => {
@@ -121,7 +121,7 @@ test('additionalProperties - boolean coerce', (t) => {
121121
})
122122

123123
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}')
125125
})
126126

127127
test('additionalProperties - object coerce', (t) => {
@@ -141,7 +141,7 @@ test('additionalProperties - object coerce', (t) => {
141141
})
142142

143143
const obj = { objfoo: { answer: 42 } }
144-
t.equal(stringify(obj), '{"objfoo":{"answer":42}}')
144+
t.assert.equal(stringify(obj), '{"objfoo":{"answer":42}}')
145145
})
146146

147147
test('additionalProperties - array coerce', (t) => {
@@ -159,10 +159,10 @@ test('additionalProperties - array coerce', (t) => {
159159
})
160160

161161
const coercibleValues = { arrfoo: [1, 2] }
162-
t.equal(stringify(coercibleValues), '{"arrfoo":["1","2"]}')
162+
t.assert.equal(stringify(coercibleValues), '{"arrfoo":["1","2"]}')
163163

164164
const incoercibleValues = { foo: 'true', ofoo: 0, objfoo: { tyrion: 'lannister' } }
165-
t.throws(() => stringify(incoercibleValues))
165+
t.assert.throws(() => stringify(incoercibleValues))
166166
})
167167

168168
test('additionalProperties with empty schema', (t) => {
@@ -173,7 +173,7 @@ test('additionalProperties with empty schema', (t) => {
173173
})
174174

175175
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}')
177177
})
178178

179179
test('additionalProperties with nested empty schema', (t) => {
@@ -187,7 +187,7 @@ test('additionalProperties with nested empty schema', (t) => {
187187
})
188188

189189
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}}')
191191
})
192192

193193
test('nested additionalProperties', (t) => {
@@ -207,7 +207,7 @@ test('nested additionalProperties', (t) => {
207207
})
208208

209209
const obj = [{ ap: { value: 'string' } }]
210-
t.equal(stringify(obj), '[{"ap":{"value":"string"}}]')
210+
t.assert.equal(stringify(obj), '[{"ap":{"value":"string"}}]')
211211
})
212212

213213
test('very nested additionalProperties', (t) => {
@@ -244,7 +244,7 @@ test('very nested additionalProperties', (t) => {
244244
})
245245

246246
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"}}}}}]')
248248
})
249249

250250
test('nested additionalProperties set to true', (t) => {
@@ -261,7 +261,7 @@ test('nested additionalProperties set to true', (t) => {
261261
})
262262

263263
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}}')
265265
})
266266

267267
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) =>
278278
})
279279

280280
const obj = { ap: { value: 'string', someNumber: undefined } }
281-
t.equal(stringify(obj), '{"ap":{"value":"string"}}')
281+
t.assert.equal(stringify(obj), '{"ap":{"value":"string"}}')
282282
})
283283

284284
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', (
294294
})
295295

296296
const obj = { ap: { additional: 'field' } }
297-
t.equal(stringify(obj), '{"ap":{"additional":"field"}}')
297+
t.assert.equal(stringify(obj), '{"ap":{"additional":"field"}}')
298298
})
299299

300300
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
311311
})
312312

313313
const obj = { ap: { additional: 'field' } }
314-
t.equal(stringify(obj), '{"ap":{}}')
314+
t.assert.equal(stringify(obj), '{"ap":{}}')
315315
})
316316

317317
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) => {
328328
})
329329

330330
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"}')
332332
})

0 commit comments

Comments
 (0)