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