Skip to content

Commit 61c443c

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

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

test/graceful-shutdown.test.js

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

3-
const t = require('tap')
3+
const { test } = require('node:test')
44
// 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
5+
const testWin = (process.platform === 'win32') ? test.skip : test
66
const sinon = require('sinon')
77
const start = require('../start')
88

99
let _port = 3001
10-
1110
function getPort () {
1211
return '' + _port++
1312
}
@@ -17,35 +16,33 @@ let fastify = null
1716
let signalCounter = null
1817
const sandbox = sinon.createSandbox()
1918

20-
t.beforeEach(async () => {
19+
test.beforeEach(async () => {
2120
signalCounter = process.listenerCount('SIGINT')
2221

2322
const argv = ['-p', getPort(), './examples/plugin.js']
2423
fastify = await start.start(argv)
2524
spy = sinon.spy(fastify, 'close')
2625
})
2726

28-
t.afterEach(async () => {
27+
test.afterEach(async () => {
2928
sandbox.restore()
3029
})
3130

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

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

3736
await fastify.close()
3837

39-
t.equal(process.listenerCount('SIGINT'), signalCounter)
40-
41-
t.end()
38+
t.assert.strictEqual(process.listenerCount('SIGINT'), signalCounter)
4239
})
4340

4441
test('should have called fastify.close() when receives a SIGINT signal', async t => {
4542
process.once('SIGINT', () => {
4643
sinon.assert.called(spy)
4744

48-
t.end()
45+
t.assert.ok('SIGINT signal handler called')
4946

5047
process.exit()
5148
})

0 commit comments

Comments
 (0)