it('does not create an HTTP server if `http` is `null`', async () => { gasketAPI.config = { hostname: 'local.gasket.godaddy.com', http: null, https: { port: 3000 } }; await start(); const createServerOpts = createServersModule.lastCall.args[0]; assume(createServerOpts).to.not.haveOwnProperty('http'); assume(createServerOpts).to.haveOwnProperty('https'); });
describe('toc-link-plugin', () => { afterEach(() => { global.window.$docsify = {}; delete global.window.Docsify; }); it('installs the plugin', () => { assume(global.window.$docsify).not.property('plugins'); setup(); assume(global.window.$docsify).property('plugins'); global.window.$docsify = {}; }); });
it('skips generate actions with --no-generate', async () => { const cmd = new CreateCommand(['myapp', '--no-generate', '--presets=nextjs']); await cmd.run(); assume(actionStubs.promptHooks).not.called(); });
it('does not add lint scripts if already set', async () => { pkgHas.callsFake((_, name) => ['eslint', 'lint'].includes(name)); await codeStyle.create(context, utils); assume(pkgAdd).not.calledWithMatch('scripts', { 'lint': sinon.match.string, 'lint:fix': sinon.match.string }); });
it('stylelintConfig question not shown if addStylelint=false', async () => { await promptHook(gasket, context, { prompt }); const question = prompt.getCall(0).args[0][3]; assume(question.name).equals('stylelintConfig'); assume(question.when({ addStylelint: false, codeStyle: 'other' })).not.true(); assume(question.when({ addStylelint: false, codeStyle: 'godaddy' })).not.true(); });
it('adds the compression middleware when enabled from gasket config', async () => { gasket.config.express = { compression: true }; await plugin.hooks.createServers(gasket, {}); const compressionUsage = findCall( app.use, mw => mw === compressionMiddleware); assume(compressionUsage).to.not.be.null(); });
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('stylelintConfig question shown when codeStyle is `other`', async () => { await promptHook(gasket, context, { prompt }); const question = prompt.getCall(0).args[0][3]; assume(question.name).equals('stylelintConfig'); assume(question.when({ addStylelint: true, codeStyle: 'other' })).true(); assume(question.when({ addStylelint: true, codeStyle: 'godaddy' })).not.true(); });
it('defaults HTTP server to port 80 if neither `http` or `https`', async () => { gasketAPI.config = {}; await start(); const createServerOpts = createServersModule.lastCall.args[0]; assume(createServerOpts).property('http', 80); assume(createServerOpts).not.property('https'); });
it('does not create an HTTPS server if `https` is `null`', async () => { gasketAPI.config = { hostname: 'local.gasket.godaddy.com', http: 8080, https: null }; await start(); const createServerOpts = createServersModule.lastCall.args[0]; assume(createServerOpts).to.haveOwnProperty('http'); assume(createServerOpts).to.not.haveOwnProperty('https'); });
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('does not add posttest script if set', async () => { pkgHas.callsFake((_, name) => ['posttest', 'eslint', 'stylelint'].includes(name)); await codeStyle.create(context, utils); assume(pkgAdd).not.calledWithMatch('scripts', { posttest: sinon.match.string }); });
it('skips generate actions with --no-generate', async () => { const cmd = new CreateCommand(['myapp', '--no-generate', '--presets=nextjs']); await cmd.run(); assume(actionStubs.promptHooks).not.called(); });
it('does not add posttest script if no eslint or stylelint', async () => { pkgHas.callsFake((_, name) => [].includes(name)); await codeStyle.create(context, utils); assume(pkgAdd).not.calledWithMatch('scripts', { posttest: sinon.match.string }); });
it('stylelintConfig question not shown if addStylelint=false', async () => { await promptHook(gasket, context, { prompt }); const question = prompt.getCall(0).args[0][3]; assume(question.name).equals('stylelintConfig'); assume(question.when({ addStylelint: false, codeStyle: 'other' })).not.true(); assume(question.when({ addStylelint: false, codeStyle: 'godaddy' })).not.true(); });