UNPKG

timpla

Version:

An optimal website development experience for [server-side] web frameworks.

40 lines (35 loc) 1.08 kB
jest.mock('../../gulpfile.ts/internal') const cb = jest.fn() const mockedOpen = jest.fn() jest.mock('open', () => mockedOpen) import { TIMPLA_DEFAULTS } from '../../gulpfile.ts/lib/TIMPLA_DEFAULTS' import { IFullTimplaConfig } from '../../gulpfile.ts/lib/TIMPLA_INTERFACES' import { open as openTask } from '../../gulpfile.ts/tasks/open' import { clone } from '../helpers' beforeEach(() => { jest.resetAllMocks() }) describe('openTask', () => { it('should open the specified target', () => { const conf: IFullTimplaConfig = clone(TIMPLA_DEFAULTS) conf.development.open = { target: 'hello', } const opnOptions = conf.development.open if (!opnOptions) { return } const open = openTask(conf) open(cb) expect(mockedOpen).toHaveBeenCalledWith('hello', { wait: false, }) }) it('should call the gulp cb if the task is disabled', () => { const conf: IFullTimplaConfig = clone(TIMPLA_DEFAULTS) conf.development.open = false const open = openTask(conf) open(cb) expect(cb).toHaveBeenCalled() }) })