UNPKG

timpla

Version:

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

45 lines (39 loc) 1.58 kB
jest.mock('../../gulpfile.ts/internal') jest.mock('gulp') const mockedChanged = jest.fn() jest.mock('gulp-changed', () => mockedChanged) 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 { fonts as fontsTask } from '../../gulpfile.ts/tasks/fonts' import { clone } from '../helpers' describe('fontsTask', () => { it('should correctly pipe assets', () => { const conf: IFullTimplaConfig = clone(TIMPLA_DEFAULTS) if (!conf.fonts) { return } const fonts = fontsTask(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') fonts(cb) expect(spyProjectSrcPath).toHaveBeenCalledWith(conf.fonts.src, '**/*.{woff2,woff,eot,ttf,svg}') expect(spyProjectDestPath).toHaveBeenCalledWith(conf.fonts.dest) expect(spyBrowserSync).toHaveBeenCalled() expect(spyGulpDest).toHaveBeenCalled() expect(mockedChanged).toHaveBeenCalled() }) it('should call the gulp cb if the task is disabled', () => { const conf: IFullTimplaConfig = clone(TIMPLA_DEFAULTS) conf.fonts = false const fonts = fontsTask(conf) fonts(cb) expect(cb).toHaveBeenCalled() }) })