it('has expected hooks', () => { const expected = [ 'init', 'metadata' ]; assume(plugin).to.have.property('hooks'); const hooks = Object.keys(plugin.hooks); assume(hooks).eqls(expected); assume(hooks).is.length(expected.length); });
describe('metadata', () => { it('retains acquired plugin data', () => { const mockData = { name: '@gasket/plugin-mock' }; const results = plugin.hooks.metadata(gasket, mockData); assume(results).property('name', '@gasket/plugin-mock'); }); it('adds lifecycles', () => { const mockData = { name: '@gasket/plugin-mock' }; const results = plugin.hooks.metadata(gasket, mockData); assume(results).property('lifecycles'); }); });
it('supports multiple presets', async () => { mockContext.rawPresets = ['@gasket/preset-bogus@^1.0.0', '@gasket/preset-all-i-ever-wanted@^2.0.0']; await loadPreset(mockContext); assume(mockContext).to.have.deep.property('presets', ['@gasket/bogus', '@gasket/all-i-ever-wanted']); assume(mockContext.presetInfos).to.lengthOf(2); });
describe('allowExtantOverwriting', () => { it('does not set confirm if not an extant directory', async () => { await allowExtantOverwriting(mockContext); assume(mockContext).does.not.own('destOverride'); }); it('sets confirm in context', async () => { promptStub.returns({ destOverride: 'roger roger' }); mockContext.extant = true; await allowExtantOverwriting(mockContext); assume(mockContext).property('destOverride', 'roger roger'); }); });
it('includes `nextConfig` from gasket.config', async () => { gasket.config.nextConfig = { customConfig: true }; result = await createConfig(gasket); assume(result).has.property('customConfig', true); });
it('relinks plugin instances to preset children (broken by clone)', async () => { assume(gasket.metadata.presets[0].plugins[0]).equals(gasket.metadata.plugins[0]); gasket.metadata.plugins[0].something = 'changed'; assume(gasket.metadata.presets[0].plugins[0]).property('something', 'changed'); });
it('adds the preset version from rawPresets', async () => { mockContext.presetInfos[0].rawName = '@gasket/preset-bogus@4.5.6'; await setupPkg.wrapped(mockContext); assume(mockContext.pkg.fields).property('dependencies'); assume(mockContext.pkg.fields.dependencies).property('@gasket/preset-bogus', '4.5.6'); });
it('instantiates PackageJson app name and description', async () => { await setupPkg.wrapped(mockContext); assume(packageJsonSpy).is.called(); assume(packageJsonSpy.args[0][0]).property('name', mockContext.appName); assume(packageJsonSpy.args[0][0]).property('description', mockContext.appDescription); });
it('config modifies urls to use zone relative path with trailing slash', async () => { const zone = '/some/asset/prefix/'; gasketAPI.config = { zone }; const results = await plugin.hooks.workbox(gasketAPI); assume(results.modifyURLPrefix).to.have.property('.next/', `${zone}_next/`); });
it('config modifies urls to use zone relative path without trailing slash', async () => { const zone = '/some/asset/prefix'; gasketAPI.config = { zone }; const results = await plugin.hooks.workbox(gasketAPI); assume(results.modifyURLPrefix).to.have.property('.next/', `${zone}/_next/`); });
it('adds the preset version with presetPath', async () => { mockContext.presetInfos[0].rawName = '@gasket/preset-bogus@file:/path/to/preset'; await setupPkg.wrapped(mockContext); assume(mockContext.pkg.fields).property('dependencies'); assume(mockContext.pkg.fields.dependencies).property('@gasket/preset-bogus', 'file:/path/to/preset'); });