UNPKG

timpla

Version:

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

42 lines (36 loc) 1.43 kB
jest.mock('../../gulpfile.ts/internal') jest.mock('gulp') jest.mock('browser-sync') const cb = jest.fn() import * as browserSync from 'browser-sync' 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 { html as htmlTask } from '../../gulpfile.ts/tasks/html' import { clone } from '../helpers' describe('htmlTask', () => { it('should correctly pipe assets', () => { const conf: IFullTimplaConfig = clone(TIMPLA_DEFAULTS) if (!conf.html) { return } const html = htmlTask(conf) const spyProjectSrcPath = jest.spyOn(internal, 'projectSrcPath') const spyProjectDestPath = jest.spyOn(internal, 'projectDestPath') const spyBrowserSync = jest.spyOn(browserSync, 'stream') const spyGulpDest = jest.spyOn(gulp, 'dest') html(cb) expect(spyProjectSrcPath).toHaveBeenCalledWith(conf.html.src, '**/*.html') expect(spyProjectDestPath).toHaveBeenCalledWith(conf.html.dest) expect(spyBrowserSync).toHaveBeenCalled() expect(spyGulpDest).toHaveBeenCalled() }) it('should call the gulp cb if the task is disabled', () => { const conf: IFullTimplaConfig = clone(TIMPLA_DEFAULTS) conf.html = false const html = htmlTask(conf) html(cb) expect(cb).toHaveBeenCalled() }) })