UNPKG

timpla

Version:

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

40 lines (34 loc) 1.36 kB
jest.mock('gulp') jest.mock('gulp-rev') const mockRevRewrite = jest.fn() jest.mock('gulp-rev-rewrite', () => mockRevRewrite) jest.mock('../../gulpfile.ts/internal') import * as gulp from 'gulp' import * as internal from '../../gulpfile.ts/internal' import { TIMPLA_DEFAULTS } from '../../gulpfile.ts/lib/TIMPLA_DEFAULTS' import { IFullTimplaConfig } from '../../gulpfile.ts/lib/TIMPLA_INTERFACES' import { rev as revTask } from '../../gulpfile.ts/tasks/rev' import { clone } from '../helpers' const cb = jest.fn() describe('revTask', () => { it('should call the tasks', () => { const conf: IFullTimplaConfig = clone(TIMPLA_DEFAULTS) const rev = revTask(conf) const spySetDisplayName = jest.spyOn(internal, 'setDisplayName') const spyRevNapkin = jest.spyOn(internal, 'revNapkin') const spySeries = jest.spyOn(gulp, 'series') const configuredSpySeries = jest.fn() configuredSpySeries.mockImplementation((rb: any) => rb()) spySeries.mockImplementation((...args) => { args.forEach((fn: any) => fn()) return configuredSpySeries }) spySetDisplayName.mockImplementation((n: any) => n) rev(cb) expect(cb).toHaveBeenCalled() expect(spyRevNapkin).toHaveBeenCalled() expect(mockRevRewrite).toHaveBeenCalled() const numTasks = 4 expect(spySeries.mock.calls[0].length).toEqual(numTasks) }) })