Sha256: e0ceb39ed14305a51247e7d4e1b2b027414fc629bedf2c00494049af84a7b99b
Contents?: true
Size: 1.72 KB
Versions: 26
Compression:
Stored size: 1.72 KB
Contents
import { SetupWorkerInternalContext, StartOptions } from '../../glossary' import { DEFAULT_START_OPTIONS, resolveStartOptions, prepareStartHandler, } from './prepareStartHandler' describe('resolveStartOptions', () => { test('returns default options given no custom start options', () => { expect(resolveStartOptions()).toEqual(DEFAULT_START_OPTIONS) expect(resolveStartOptions(undefined)).toEqual(DEFAULT_START_OPTIONS) expect(resolveStartOptions({})).toEqual(DEFAULT_START_OPTIONS) }) test('deeply merges the default and custom start options', () => { expect( resolveStartOptions({ quiet: true, serviceWorker: { url: './custom.js', }, }), ).toEqual({ ...DEFAULT_START_OPTIONS, quiet: true, serviceWorker: { url: './custom.js', options: null, }, }) }) }) describe('prepareStartHandler', () => { test('exposes resolved start options to the generated star handler', () => { const createStartHandler = vi.fn() const context: SetupWorkerInternalContext = {} as any const startHandler = prepareStartHandler(createStartHandler, context) expect(startHandler).toBeInstanceOf(Function) const initialOptions: StartOptions = { quiet: true, serviceWorker: { url: './custom.js', }, } const resolvedOptions = resolveStartOptions(initialOptions) startHandler(initialOptions) // Calls the handler creator with both resolved and initial options. expect(createStartHandler).toHaveBeenCalledWith( resolvedOptions, initialOptions, ) // Sets the resolved options on the internal context. expect(context).toHaveProperty('startOptions', resolvedOptions) }) })
Version data entries
26 entries across 26 versions & 1 rubygems