Files
infocom-systems-design/node_modules/process-warning/test/emit-once-only.test.js
2025-10-03 22:27:28 +03:00

29 lines
595 B
JavaScript

'use strict'
const test = require('tap').test
const { createWarning } = require('..')
test('emit should emit a given code only once', t => {
t.plan(4)
process.on('warning', onWarning)
function onWarning (warning) {
t.equal(warning.name, 'TestDeprecation')
t.equal(warning.code, 'CODE')
t.equal(warning.message, 'Hello world')
t.ok(warn.emitted)
}
const warn = createWarning({
name: 'TestDeprecation',
code: 'CODE',
message: 'Hello world'
})
warn()
warn()
setImmediate(() => {
process.removeListener('warning', onWarning)
t.end()
})
})