Skip to content

Commit bc7c85d

Browse files
committed
feat: converted all the tap tests with node:test
1 parent 665d0b2 commit bc7c85d

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

+1253
-1957
lines changed

Diff for: .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/

Diff for: .taprc

-7
This file was deleted.

Diff for: package.json

+1-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": "node --test",
1717
"test": "npm run test:unit && npm run test:typescript"
1818
},
1919
"precommit": [
@@ -46,7 +46,6 @@
4646
"is-my-json-valid": "^2.20.6",
4747
"simple-git": "^3.23.0",
4848
"standard": "^17.1.0",
49-
"tap": "^19.2.5",
5049
"tsd": "^0.31.0",
5150
"webpack": "^5.90.3"
5251
},

Diff for: test/additionalProperties.test.js

+39-56
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use strict'
22

3-
const test = require('tap').test
3+
const { describe } = require('node:test')
4+
const { deepStrictEqual, throws } = require('node:assert')
45
const build = require('..')
56

6-
test('additionalProperties', (t) => {
7-
t.plan(1)
7+
describe('additionalProperties', () => {
88
const stringify = build({
99
title: 'additionalProperties',
1010
type: 'object',
@@ -19,11 +19,10 @@ 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+
deepStrictEqual(stringify(obj), '{"str":"test","foo":"42","ofoo":"true","foof":"string","objfoo":"[object Object]"}')
2323
})
2424

25-
test('additionalProperties should not change properties', (t) => {
26-
t.plan(1)
25+
describe('additionalProperties should not change properties', () => {
2726
const stringify = build({
2827
title: 'patternProperties should not change properties',
2928
type: 'object',
@@ -38,11 +37,10 @@ test('additionalProperties should not change properties', (t) => {
3837
})
3938

4039
const obj = { foo: '42', ofoo: 42 }
41-
t.equal(stringify(obj), '{"foo":"42","ofoo":42}')
40+
deepStrictEqual(stringify(obj), '{"foo":"42","ofoo":42}')
4241
})
4342

44-
test('additionalProperties should not change properties and patternProperties', (t) => {
45-
t.plan(1)
43+
describe('additionalProperties should not change properties and patternProperties', () => {
4644
const stringify = build({
4745
title: 'patternProperties should not change properties',
4846
type: 'object',
@@ -62,11 +60,10 @@ test('additionalProperties should not change properties and patternProperties',
6260
})
6361

6462
const obj = { foo: '42', ofoo: 42, test: '42' }
65-
t.equal(stringify(obj), '{"foo":"42","ofoo":"42","test":42}')
63+
deepStrictEqual(stringify(obj), '{"foo":"42","ofoo":"42","test":42}')
6664
})
6765

68-
test('additionalProperties set to true, use of fast-safe-stringify', (t) => {
69-
t.plan(1)
66+
describe('additionalProperties set to true, use of fast-safe-stringify', () => {
7067
const stringify = build({
7168
title: 'check string coerce',
7269
type: 'object',
@@ -75,11 +72,10 @@ test('additionalProperties set to true, use of fast-safe-stringify', (t) => {
7572
})
7673

7774
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"}}')
75+
deepStrictEqual(stringify(obj), '{"foo":true,"ofoo":42,"arrfoo":["array","test"],"objfoo":{"a":"world"}}')
7976
})
8077

81-
test('additionalProperties - string coerce', (t) => {
82-
t.plan(1)
78+
describe('additionalProperties - string coerce', () => {
8379
const stringify = build({
8480
title: 'check string coerce',
8581
type: 'object',
@@ -90,11 +86,10 @@ test('additionalProperties - string coerce', (t) => {
9086
})
9187

9288
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]"}')
89+
deepStrictEqual(stringify(obj), '{"foo":"true","ofoo":"42","arrfoo":"array,test","objfoo":"[object Object]"}')
9490
})
9591

96-
test('additionalProperties - number skip', (t) => {
97-
t.plan(1)
92+
describe('additionalProperties - number skip', () => {
9893
const stringify = build({
9994
title: 'check number coerce',
10095
type: 'object',
@@ -106,11 +101,10 @@ test('additionalProperties - number skip', (t) => {
106101

107102
// const obj = { foo: true, ofoo: '42', xfoo: 'string', arrfoo: [1, 2], objfoo: { num: 42 } }
108103
const obj = { foo: true, ofoo: '42' }
109-
t.equal(stringify(obj), '{"foo":1,"ofoo":42}')
104+
deepStrictEqual(stringify(obj), '{"foo":1,"ofoo":42}')
110105
})
111106

112-
test('additionalProperties - boolean coerce', (t) => {
113-
t.plan(1)
107+
describe('additionalProperties - boolean coerce', () => {
114108
const stringify = build({
115109
title: 'check boolean coerce',
116110
type: 'object',
@@ -121,11 +115,10 @@ test('additionalProperties - boolean coerce', (t) => {
121115
})
122116

123117
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}')
118+
deepStrictEqual(stringify(obj), '{"foo":true,"ofoo":false,"arrfoo":true,"objfoo":true}')
125119
})
126120

127-
test('additionalProperties - object coerce', (t) => {
128-
t.plan(1)
121+
describe('additionalProperties - object coerce', () => {
129122
const stringify = build({
130123
title: 'check object coerce',
131124
type: 'object',
@@ -141,11 +134,10 @@ test('additionalProperties - object coerce', (t) => {
141134
})
142135

143136
const obj = { objfoo: { answer: 42 } }
144-
t.equal(stringify(obj), '{"objfoo":{"answer":42}}')
137+
deepStrictEqual(stringify(obj), '{"objfoo":{"answer":42}}')
145138
})
146139

147-
test('additionalProperties - array coerce', (t) => {
148-
t.plan(2)
140+
describe('additionalProperties - array coerce', () => {
149141
const stringify = build({
150142
title: 'check array coerce',
151143
type: 'object',
@@ -159,25 +151,23 @@ test('additionalProperties - array coerce', (t) => {
159151
})
160152

161153
const coercibleValues = { arrfoo: [1, 2] }
162-
t.equal(stringify(coercibleValues), '{"arrfoo":["1","2"]}')
154+
deepStrictEqual(stringify(coercibleValues), '{"arrfoo":["1","2"]}')
163155

164156
const incoercibleValues = { foo: 'true', ofoo: 0, objfoo: { tyrion: 'lannister' } }
165-
t.throws(() => stringify(incoercibleValues))
157+
throws(() => stringify(incoercibleValues))
166158
})
167159

168-
test('additionalProperties with empty schema', (t) => {
169-
t.plan(1)
160+
describe('additionalProperties with empty schema', () => {
170161
const stringify = build({
171162
type: 'object',
172163
additionalProperties: {}
173164
})
174165

175166
const obj = { a: 1, b: true, c: null }
176-
t.equal(stringify(obj), '{"a":1,"b":true,"c":null}')
167+
deepStrictEqual(stringify(obj), '{"a":1,"b":true,"c":null}')
177168
})
178169

179-
test('additionalProperties with nested empty schema', (t) => {
180-
t.plan(1)
170+
describe('additionalProperties with nested empty schema', () => {
181171
const stringify = build({
182172
type: 'object',
183173
properties: {
@@ -187,11 +177,10 @@ test('additionalProperties with nested empty schema', (t) => {
187177
})
188178

189179
const obj = { data: { a: 1, b: true, c: null } }
190-
t.equal(stringify(obj), '{"data":{"a":1,"b":true,"c":null}}')
180+
deepStrictEqual(stringify(obj), '{"data":{"a":1,"b":true,"c":null}}')
191181
})
192182

193-
test('nested additionalProperties', (t) => {
194-
t.plan(1)
183+
describe('nested additionalProperties', () => {
195184
const stringify = build({
196185
title: 'additionalProperties',
197186
type: 'array',
@@ -207,11 +196,10 @@ test('nested additionalProperties', (t) => {
207196
})
208197

209198
const obj = [{ ap: { value: 'string' } }]
210-
t.equal(stringify(obj), '[{"ap":{"value":"string"}}]')
199+
deepStrictEqual(stringify(obj), '[{"ap":{"value":"string"}}]')
211200
})
212201

213-
test('very nested additionalProperties', (t) => {
214-
t.plan(1)
202+
describe('very nested additionalProperties', () => {
215203
const stringify = build({
216204
title: 'additionalProperties',
217205
type: 'array',
@@ -244,11 +232,10 @@ test('very nested additionalProperties', (t) => {
244232
})
245233

246234
const obj = [{ ap: { nested: { moarNested: { finally: { value: 'str' } } } } }]
247-
t.equal(stringify(obj), '[{"ap":{"nested":{"moarNested":{"finally":{"value":"str"}}}}}]')
235+
deepStrictEqual(stringify(obj), '[{"ap":{"nested":{"moarNested":{"finally":{"value":"str"}}}}}]')
248236
})
249237

250-
test('nested additionalProperties set to true', (t) => {
251-
t.plan(1)
238+
describe('nested additionalProperties set to true', () => {
252239
const stringify = build({
253240
title: 'nested additionalProperties=true',
254241
type: 'object',
@@ -261,11 +248,10 @@ test('nested additionalProperties set to true', (t) => {
261248
})
262249

263250
const obj = { ap: { value: 'string', someNumber: 42 } }
264-
t.equal(stringify(obj), '{"ap":{"value":"string","someNumber":42}}')
251+
deepStrictEqual(stringify(obj), '{"ap":{"value":"string","someNumber":42}}')
265252
})
266253

267-
test('field passed to fastSafeStringify as undefined should be removed', (t) => {
268-
t.plan(1)
254+
describe('field passed to fastSafeStringify as undefined should be removed', () => {
269255
const stringify = build({
270256
title: 'nested additionalProperties=true',
271257
type: 'object',
@@ -278,11 +264,10 @@ test('field passed to fastSafeStringify as undefined should be removed', (t) =>
278264
})
279265

280266
const obj = { ap: { value: 'string', someNumber: undefined } }
281-
t.equal(stringify(obj), '{"ap":{"value":"string"}}')
267+
deepStrictEqual(stringify(obj), '{"ap":{"value":"string"}}')
282268
})
283269

284-
test('property without type but with enum, will acts as additionalProperties', (t) => {
285-
t.plan(1)
270+
describe('property without type but with enum, will acts as additionalProperties', () => {
286271
const stringify = build({
287272
title: 'automatic additionalProperties',
288273
type: 'object',
@@ -294,11 +279,10 @@ test('property without type but with enum, will acts as additionalProperties', (
294279
})
295280

296281
const obj = { ap: { additional: 'field' } }
297-
t.equal(stringify(obj), '{"ap":{"additional":"field"}}')
282+
deepStrictEqual(stringify(obj), '{"ap":{"additional":"field"}}')
298283
})
299284

300-
test('property without type but with enum, will acts as additionalProperties without overwriting', (t) => {
301-
t.plan(1)
285+
describe('property without type but with enum, will acts as additionalProperties without overwriting', () => {
302286
const stringify = build({
303287
title: 'automatic additionalProperties',
304288
type: 'object',
@@ -311,11 +295,10 @@ test('property without type but with enum, will acts as additionalProperties wit
311295
})
312296

313297
const obj = { ap: { additional: 'field' } }
314-
t.equal(stringify(obj), '{"ap":{}}')
298+
deepStrictEqual(stringify(obj), '{"ap":{}}')
315299
})
316300

317-
test('function and symbol references are not serialized as undefined', (t) => {
318-
t.plan(1)
301+
describe('function and symbol references are not serialized as undefined', () => {
319302
const stringify = build({
320303
title: 'additionalProperties',
321304
type: 'object',
@@ -328,5 +311,5 @@ test('function and symbol references are not serialized as undefined', (t) => {
328311
})
329312

330313
const obj = { str: 'x', test: 'test', meth: () => 'x', sym: Symbol('x') }
331-
t.equal(stringify(obj), '{"str":"x","test":"test"}')
314+
deepStrictEqual(stringify(obj), '{"str":"x","test":"test"}')
332315
})

0 commit comments

Comments
 (0)