You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

33 lines
625 B

var test = require('tap').test
var inf = require('./inflight.js')
function req (key, cb) {
cb = inf(key, cb)
if (cb) setTimeout(function () {
cb(key)
cb(key)
})
return cb
}
test('basic', function (t) {
var calleda = false
var a = req('key', function (k) {
t.notOk(calleda)
calleda = true
t.equal(k, 'key')
if (calledb) t.end()
})
t.ok(a, 'first returned cb function')
var calledb = false
var b = req('key', function (k) {
t.notOk(calledb)
calledb = true
t.equal(k, 'key')
if (calleda) t.end()
})
t.notOk(b, 'second should get falsey inflight response')
})