First commit
This commit is contained in:
26
node_modules/process-warning/test/emit-once-only.test.js
generated
vendored
Normal file
26
node_modules/process-warning/test/emit-once-only.test.js
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
'use strict'
|
||||
|
||||
const test = require('tap').test
|
||||
const build = require('..')
|
||||
|
||||
test('emit should emit a given code only once', t => {
|
||||
t.plan(4)
|
||||
|
||||
const { create, emit, emitted } = build()
|
||||
|
||||
process.on('warning', onWarning)
|
||||
function onWarning (warning) {
|
||||
t.equal(warning.name, 'FastifyDeprecation')
|
||||
t.equal(warning.code, 'CODE')
|
||||
t.equal(warning.message, 'Hello world')
|
||||
t.ok(emitted.get('CODE'))
|
||||
}
|
||||
|
||||
create('FastifyDeprecation', 'CODE', 'Hello world')
|
||||
emit('CODE')
|
||||
emit('CODE')
|
||||
setImmediate(() => {
|
||||
process.removeListener('warning', onWarning)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user