UNPKG

timpla

Version:

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

42 lines (38 loc) 1.44 kB
const cb = jest.fn() const mockedChanged = jest.fn() jest.mock('../../gulpfile.ts/internal') jest.mock('gulp') jest.mock('gulp-changed', () => mockedChanged) 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 { images as imagesTask } from '../../gulpfile.ts/tasks/images' import { clone } from '../helpers' describe('imagesTask', () => { it('should correctly pipe assets', () => { const conf: IFullTimplaConfig = clone(TIMPLA_DEFAULTS) if (!conf.images) { return } const images = imagesTask(conf) const spyProjectSrcPath = jest.spyOn(internal, 'projectSrcPath') const spyProjectDestPath = jest.spyOn(internal, 'projectDestPath') const spyGulpDest = jest.spyOn(gulp, 'dest') images(cb) expect(spyProjectSrcPath).toHaveBeenCalledWith( conf.images.src, '**/*.{jpg,jpeg,png,svg,gif,webp}' ) expect(spyProjectDestPath).toHaveBeenCalledWith(conf.images.dest) expect(spyGulpDest).toHaveBeenCalled() expect(mockedChanged).toHaveBeenCalled() }) it('should call the gulp cb if the task is disabled', () => { const conf: IFullTimplaConfig = clone(TIMPLA_DEFAULTS) conf.images = false const images = imagesTask(conf) images(cb) expect(cb).toHaveBeenCalled() }) })