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' )
64const sinon = require ( 'sinon' )
75const start = require ( '../start' )
86
97let _port = 3001
10-
118function getPort ( ) {
129 return '' + _port ++
1310}
@@ -17,35 +14,33 @@ let fastify = null
1714let signalCounter = null
1815const 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
4439test ( '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