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); });
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); });
it('exposes defaults as statics', function () { assume(Log.prefix).to.equal('server'); assume(Log.format).to.have.property('color'); assume(Log.Console).to.equal(transports.Console); });
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('adds presetInfos to context', async () => { await loadPreset(mockContext); assume(mockContext).to.have.deep.property('presetInfos', [{ ...mockPkgs['@gasket/preset-bogus@^1.0.0'], from: 'cli', rawName: '@gasket/preset-bogus@^1.0.0', presets: [{ package: { name: '@gasket/preset-some', version: '1.0.1' }, from: '@gasket/preset-bogus', rawName: '@gasket/preset-some@1.0.1' }] }]); });
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('has expected hooks', () => { const expected = [ 'init', 'create', 'destroy', 'metadata' ]; assume(Plugin).to.have.property('hooks'); const hooks = Object.keys(Plugin.hooks); assume(hooks).eqls(expected); assume(hooks).is.length(expected.length); });
it('config modifies urls to use zone with https', async () => { const zone = 'https://some-cdn.com/'; 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 with https but no trailing slash', async () => { const zone = 'https://some-cdn.com'; 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 assetPrefix with http', async () => { const assetPrefix = 'http://some-cdn.com/'; gasketAPI.config = { next: { assetPrefix } }; const results = await plugin.hooks.workbox(gasketAPI); assume(results.modifyURLPrefix).to.have.property('.next/', assetPrefix + '_next/'); });
it('adds presetInfos to context', async () => { await loadPreset(mockContext); assume(mockContext).to.have.deep.property('presetInfos', [{ ...mockPkgs['@gasket/preset-bogus@^1.0.0'], from: 'cli', rawName: '@gasket/preset-bogus@^1.0.0', presets: [{ package: { name: '@gasket/preset-some', version: '1.0.1' }, from: '@gasket/preset-bogus', rawName: '@gasket/preset-some@1.0.1' }] }]); });
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); });
it('config modifies urls to use zone with http', async () => { const zone = 'http://some-cdn.com/'; 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 assetPrefix with https but no trailing slash', async () => { const assetPrefix = 'https://some-cdn.com'; gasketAPI.config = { next: { assetPrefix } }; const results = await plugin.hooks.workbox(gasketAPI); assume(results.modifyURLPrefix).to.have.property('.next/', `${assetPrefix}/_next/`); });