test.cb('emitSerial()', t => { t.plan(1); const emitter = new Emittery(); const events = []; const listener = async data => { await delay(Math.random() * 100); events.push(data); if (events.length >= 5) { t.deepEqual(events, [1, 2, 3, 4, 5]); t.end(); } }; emitter.on('🦄', () => listener(1)); emitter.on('🦄', () => listener(2)); emitter.on('🦄', () => listener(3)); emitter.on('🦄', () => listener(4)); emitter.on('🦄', () => listener(5)); emitter.emitSerial('🦄', 'e'); });
test.cb('emit() - multiple events', t => { t.plan(1); const emitter = new Emittery(); let count = 0; emitter.on('🦄', async () => { await delay(Math.random() * 100); if (++count >= 5) { t.is(count, 5); t.end(); } }); emitter.emit('🦄'); emitter.emit('🦄'); emitter.emit('🦄'); emitter.emit('🦄'); emitter.emit('🦄'); });
test.cb("tests vueOptions", t => { let req = {}; let res = { response: "", set: function(key, value) { this[key] = value; }, write: function(chunk) { this.response += chunk; }, // tslint:disable-next-line:no-empty send: function(error) { }, // tslint:disable-next-line:no-empty end: function() {}, }; // tslint:disable-next-line:no-shadowed-variable function next(error, req, res) { if (error) { t.fail(error); t.end(); } } expressVueMiddleware(req, res, next); t.is(typeof res.renderVue, "function"); t.end(); });