UNPKG

timpla

Version:

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

25 lines (21 loc) 934 B
import * as internal from '../../gulpfile.ts/internal' import { lazyImport } from '../../gulpfile.ts/lib/lazyImport' jest.mock('../../gulpfile.ts/internal') const sSureLazyImport = jest.spyOn(internal, 'sureLazyImport') const sIsPackageInstalled = jest.spyOn(internal, 'isPackageInstalled') describe('lazyImport', () => { it('should import the specified package if it exists', () => { sIsPackageInstalled.mockReturnValueOnce(true) sSureLazyImport.mockReturnValueOnce(true) const result = lazyImport('hello') expect(sSureLazyImport).toHaveBeenCalledWith('hello') expect(sIsPackageInstalled).toHaveBeenCalledWith('hello') expect(result).toBeTruthy() }) it('should not import the specified package if it exists', () => { sIsPackageInstalled.mockReturnValueOnce(false) const result = lazyImport('hello') expect(result).toBeFalsy() expect(sSureLazyImport.mock.calls.length).toBe(0) }) })