test.cb('default', t => { // TODO: Use `execa` here when the `spawn` API is done const cp = childProcess.spawn('./cli.js', {stdio: 'inherit'}); cp.on('error', t.fail); cp.on('close', code => { t.is(code, 0); t.end(); }); });
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('🦄'); });
}, end: function() { t.is(this.response, exampleResponse); t.end(); },
}, send: function(error) { t.is(error.message, exampleError); t.end(); },
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(); });
test.cb('hapi should register correctly', t => { t.plan(6); const server = { log() {}, decorate(type, decorateName, configGetter) { t.assert(/server|request/.test(type)); t.is(decorateName, 'configue'); t.true(_.isFunction(configGetter)); } }; const plugin = new Configue().plugin(); plugin(server, {}, t.end); });
}, end: function() { t.is(this.response, exampleResponse); t.end(); },
// Tests test.serial.cb( 'store clear before', t => { store.clear( err => { t.is( err, null ); t.end(); } ); } );
test.cb('main', t => { const cp = childProcess.spawn('./cli.js', {stdio: 'inherit'}); cp.on('error', t.fail); cp.on('close', code => { t.is(code, 0); t.end(); }); });
test.cb('hapi should register with a custom name correctly', t => { t.plan(6); const server = { log() {}, decorate(type, decorateName, configGetter) { t.assert(/server|request/.test(type)); t.is(decorateName, 'conf'); t.true(_.isFunction(configGetter)); } }; const plugin = new Configue().plugin('conf'); plugin(server, {}, t.end); });
test.serial.cb( 'store clear', t => { store.clear( err => { t.is( err, null ); t.end(); } ); } );