/** * Simple helper to check finished state of the stream * that is `maybeDone`. * * @param {WritableStream} maybeDone Stream that may have finished. */ function assumeFinished(maybeDone) { assume(maybeDone._writableState).is.an('object'); assume(maybeDone._writableState.finished).true(); }
it('runs on the init lifecycle event', function () { assume(Plugin.hooks.init.handler).to.be.an('asyncfunction'); assume(Plugin.hooks.init.handler).to.have.length(1); });
describe('Plugin', () => { it('is an object', () => { assume(plugin).is.an('object'); }); it('has expected name', () => { assume(plugin).to.have.property('name', require('../package').name); }); it('has expected hooks', () => { const expected = [ 'metadata' ]; assume(plugin).to.have.property('hooks'); const hooks = Object.keys(plugin.hooks); assume(hooks).eqls(expected); assume(hooks).is.length(expected.length); }); });
it('returns workbox config partial', async () => { const results = await plugin.hooks.workbox(gasketAPI); assume(results).to.be.an('object'); });
describe('.destroy', function () { it('has destroy lifecycle event', function () { assume(Plugin.hooks.destroy).to.be.an('asyncfunction'); assume(Plugin.hooks.destroy).to.have.length(1); }); it('closes logger instance', async function () { const gasket = { logger: { close: sinon.spy() } }; await Plugin.hooks.destroy(gasket); assume(gasket.logger.close).is.called(); }); });
it('is an object', () => { assume(Plugin).is.an('object'); });
it('return config object for next.js', async () => { result = await createConfig(gasket); assume(result).is.an('object'); });
/** * Simple helper to check finished state of the stream * that is `maybeDone`. * * @param {WritableStream} maybeDone Stream that may have finished. */ function assumeFinished(maybeDone) { assume(maybeDone._writableState).is.an('object'); assume(maybeDone._writableState.finished).true(); }
it('runs on the init lifecycle event', function () { assume(Plugin.hooks.init.handler).to.be.an('asyncfunction'); assume(Plugin.hooks.init.handler).to.have.length(1); });
it('is an object', () => { assume(Plugin).is.an('object'); });
it('is an object', () => { assume(plugin).is.an('object'); });
it('is an object', () => { assume(plugin).is.an('object'); });
describe('.destroy', function () { it('has destroy lifecycle event', function () { assume(Plugin.hooks.destroy).to.be.an('asyncfunction'); assume(Plugin.hooks.destroy).to.have.length(1); }); it('closes logger instance', async function () { const gasket = { logger: { close: sinon.spy() } }; await Plugin.hooks.destroy(gasket); assume(gasket.logger.close).is.called(); }); });