Skip to content

Commit 2954630

Browse files
committed
test: migrated graceful-shutdown.test.js from tap to node:test
1 parent 44a2221 commit 2954630

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

test/graceful-shutdown.test.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
'use strict'
22

3-
const t = require('tap')
4-
// Tests skip on win32 platforms due SIGINT signal is not supported across all windows platforms
5-
const test = (process.platform === 'win32') ? t.skip : t.test
3+
const { test } = require('node:test')
64
const sinon = require('sinon')
75
const start = require('../start')
86

97
let _port = 3001
10-
118
function getPort () {
129
return '' + _port++
1310
}
@@ -17,35 +14,33 @@ let fastify = null
1714
let signalCounter = null
1815
const sandbox = sinon.createSandbox()
1916

20-
t.beforeEach(async () => {
17+
test.beforeEach(async () => {
2118
signalCounter = process.listenerCount('SIGINT')
2219

2320
const argv = ['-p', getPort(), './examples/plugin.js']
2421
fastify = await start.start(argv)
2522
spy = sinon.spy(fastify, 'close')
2623
})
2724

28-
t.afterEach(async () => {
25+
test.afterEach(async () => {
2926
sandbox.restore()
3027
})
3128

32-
test('should add and remove SIGINT listener as expected ', async t => {
29+
test('should add and remove SIGINT listener as expected', async (t) => {
3330
t.plan(2)
3431

35-
t.equal(process.listenerCount('SIGINT'), signalCounter + 1)
32+
t.assert.strictEqual(process.listenerCount('SIGINT'), signalCounter + 1)
3633

3734
await fastify.close()
3835

39-
t.equal(process.listenerCount('SIGINT'), signalCounter)
40-
41-
t.end()
36+
t.assert.strictEqual(process.listenerCount('SIGINT'), signalCounter)
4237
})
4338

4439
test('should have called fastify.close() when receives a SIGINT signal', async t => {
4540
process.once('SIGINT', () => {
4641
sinon.assert.called(spy)
4742

48-
t.end()
43+
t.assert.ok('SIGINT signal handler called')
4944

5045
process.exit()
5146
})

0 commit comments

Comments
 (0)