1
1
'use strict'
2
2
3
- const t = require ( 'tap ' )
3
+ const { test } = require ( 'node:test ' )
4
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
5
+ const testWin = ( process . platform === 'win32' ) ? test . skip : test
6
6
const sinon = require ( 'sinon' )
7
7
const start = require ( '../start' )
8
8
9
9
let _port = 3001
10
-
11
10
function getPort ( ) {
12
11
return '' + _port ++
13
12
}
@@ -17,35 +16,33 @@ let fastify = null
17
16
let signalCounter = null
18
17
const sandbox = sinon . createSandbox ( )
19
18
20
- t . beforeEach ( async ( ) => {
19
+ test . beforeEach ( async ( ) => {
21
20
signalCounter = process . listenerCount ( 'SIGINT' )
22
21
23
22
const argv = [ '-p' , getPort ( ) , './examples/plugin.js' ]
24
23
fastify = await start . start ( argv )
25
24
spy = sinon . spy ( fastify , 'close' )
26
25
} )
27
26
28
- t . afterEach ( async ( ) => {
27
+ test . afterEach ( async ( ) => {
29
28
sandbox . restore ( )
30
29
} )
31
30
32
- test ( 'should add and remove SIGINT listener as expected ' , async t => {
31
+ test ( 'should add and remove SIGINT listener as expected' , async ( t ) => {
33
32
t . plan ( 2 )
34
33
35
- t . equal ( process . listenerCount ( 'SIGINT' ) , signalCounter + 1 )
34
+ t . assert . strictEqual ( process . listenerCount ( 'SIGINT' ) , signalCounter + 1 )
36
35
37
36
await fastify . close ( )
38
37
39
- t . equal ( process . listenerCount ( 'SIGINT' ) , signalCounter )
40
-
41
- t . end ( )
38
+ t . assert . strictEqual ( process . listenerCount ( 'SIGINT' ) , signalCounter )
42
39
} )
43
40
44
41
test ( 'should have called fastify.close() when receives a SIGINT signal' , async t => {
45
42
process . once ( 'SIGINT' , ( ) => {
46
43
sinon . assert . called ( spy )
47
44
48
- t . end ( )
45
+ t . assert . ok ( 'SIGINT signal handler called' )
49
46
50
47
process . exit ( )
51
48
} )
0 commit comments