timpla
Version:
An optimal website development experience for [server-side] web frameworks.
28 lines (24 loc) • 1.06 kB
text/typescript
jest.mock('../../gulpfile.ts/internal')
jest.mock('fancy-log')
const mockWebpack = jest.fn().mockImplementation((config, handler) => {
handler()
})
jest.mock('webpack', () => mockWebpack)
const cb = jest.fn()
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 { webpackProduction as webpackProductionTask } from '../../gulpfile.ts/tasks/webpackProduction'
import { clone } from '../helpers'
describe('webpackProductionTask', () => {
it('should call webpack with the correct arguments', () => {
const conf: IFullTimplaConfig = clone(TIMPLA_DEFAULTS)
const webpackProduction = webpackProductionTask(conf)
const spyWebpackMultiConfig = jest.spyOn(internal, 'webpackMultiConfig')
const mockR = jest.fn().mockReturnValue({})
spyWebpackMultiConfig.mockReturnValue(mockR)
webpackProduction(cb)
expect(mockWebpack).toHaveBeenCalled()
expect(cb).toHaveBeenCalled()
})
})