it('adds stylelint scripts if stylelint present', async () => { pkgHas.callsFake((prop, name) => prop === 'devDependencies' && ['stylelint'].includes(name)); await codeStyle.create(context, utils); assume(pkgAdd).calledWithMatch('scripts', { 'stylelint': sinon.match.string, 'stylelint:fix': sinon.match.string }); assume(utils.runScriptStr).calledWith('stylelint -- --fix'); });
it('executes the `middleware` lifecycle before the `express` lifecycle', async function () { await plugin.hooks.createServers(gasket, {}); assume(gasket.exec.firstCall).has.been.calledWith('middleware', app); assume(gasket.exec.secondCall).has.been.calledWith('express', app); });
it('cleans output dir', async () => { await collateFiles(mockDocsConfigSet); assume(rimrafStub).calledWith(mockDocsConfigSet.docsRoot + '/*'); });
it('instantiates PackageManager with context', async () => { await setupPkg.wrapped(mockContext); assume(packageManagerSpy).is.calledWith(mockContext); });
it('adds posttest script for stylelint', async () => { pkgHas.callsFake((_, name) => ['stylelint'].includes(name)); await codeStyle.create(context, utils); assume(pkgAdd).calledWithMatch('scripts', { posttest: sinon.match.string }); assume(utils.runScriptStr).not.calledWith('lint'); assume(utils.runScriptStr).calledWith('stylelint'); });
it('processes all moduleDocConfigs', async () => { await collateFiles(mockDocsConfigSet); assume(processModuleSpy).calledWith(mockDocsConfigSet.plugins[0]); assume(processModuleSpy).calledWith(mockDocsConfigSet.presets[0]); assume(processModuleSpy).calledWith(mockDocsConfigSet.modules[0]); });
it('executes the `express` lifecycle', async function () { await plugin.hooks.createServers(gasket, {}); assume(gasket.exec).has.been.calledWith('express', app); });
it('adds posttest script for lint && stylelint', async () => { pkgHas.callsFake((_, name) => ['eslint', 'stylelint'].includes(name)); await codeStyle.create(context, utils); assume(pkgAdd).calledWithMatch('scripts', { posttest: sinon.match.string }); assume(utils.runScriptStr).calledWith('lint'); assume(utils.runScriptStr).calledWith('stylelint'); });
it('executes the `errorMiddleware` lifecycle after the `express` lifecycle', async function () { await plugin.hooks.createServers(gasket, {}); assume(gasket.exec.secondCall).has.been.calledWith('express', app); assume(gasket.exec.thirdCall).has.been.calledWith('errorMiddleware'); });
it('adds posttest script for eslint', async () => { pkgHas.callsFake((_, name) => ['eslint'].includes(name)); await codeStyle.create(context, utils); assume(pkgAdd).calledWithMatch('scripts', { posttest: sinon.match.string }); assume(utils.runScriptStr).calledWith('lint'); assume(utils.runScriptStr).not.calledWith('stylelint'); });
it('executes the `middleware` lifecycle before the `fastify` lifecycle', async function () { await plugin.hooks.createServers(gasket, {}); assume(gasket.exec.firstCall).has.been.calledWith('middleware', app); assume(gasket.exec.secondCall).has.been.calledWith('fastify', app); });
it('executes the `errorMiddleware` lifecycle after the `fastify` lifecycle', async function () { await plugin.hooks.createServers(gasket, {}); assume(gasket.exec.secondCall).has.been.calledWith('fastify', app); assume(gasket.exec.thirdCall).has.been.calledWith('errorMiddleware'); });
it('executes the `errorMiddleware` lifecycle after the `fastify` lifecycle', async function () { await plugin.hooks.createServers(gasket, {}); assume(gasket.exec.secondCall).has.been.calledWith('fastify', app); assume(gasket.exec.thirdCall).has.been.calledWith('errorMiddleware'); });
it('executes the `middleware` lifecycle before the `express` lifecycle', async function () { await plugin.hooks.createServers(gasket, {}); assume(gasket.exec.firstCall).has.been.calledWith('middleware', app); assume(gasket.exec.secondCall).has.been.calledWith('express', app); });
it('makes output dir', async () => { await collateFiles(mockDocsConfigSet); assume(mkdirpStub).calledWith(mockDocsConfigSet.docsRoot); });