add hw2
This commit is contained in:
36
node_modules/process-warning/test/emit-reset.test.js
generated
vendored
Normal file
36
node_modules/process-warning/test/emit-reset.test.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
'use strict'
|
||||
|
||||
const test = require('tap').test
|
||||
const { createWarning } = require('../')
|
||||
|
||||
test('a limited warning can be re-set', t => {
|
||||
t.plan(4)
|
||||
|
||||
let count = 0
|
||||
process.on('warning', onWarning)
|
||||
function onWarning () {
|
||||
count++
|
||||
}
|
||||
|
||||
const warn = createWarning({
|
||||
name: 'TestDeprecation',
|
||||
code: 'CODE',
|
||||
message: 'Hello world'
|
||||
})
|
||||
|
||||
warn()
|
||||
t.ok(warn.emitted)
|
||||
|
||||
warn()
|
||||
t.ok(warn.emitted)
|
||||
|
||||
warn.emitted = false
|
||||
warn()
|
||||
t.ok(warn.emitted)
|
||||
|
||||
setImmediate(() => {
|
||||
t.equal(count, 2)
|
||||
process.removeListener('warning', onWarning)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user