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
66const sinon = require ( 'sinon' )
77const start = require ( '../start' )
88
99let _port = 3001
10-
1110function getPort ( ) {
1211 return '' + _port ++
1312}
@@ -17,35 +16,33 @@ let fastify = null
1716let signalCounter = null
1817const 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
4441test ( '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