UNPKG

johnny-cli

Version:

CLI for Johnny Deps

32 lines (25 loc) 930 B
import Dll from '../'; import webpack from 'webpack'; import {dllWebpackConfig} from 'templates'; jest.mock('templates', () => ({dllWebpackConfig: () => 'config template'})); jest.mock('webpack', () => (config, callback) => callback(null, {hasErrors: () => false})); jest.mock('fs'); import fs from 'fs'; const dllPath = './dll'; let dll = Dll({path: dllPath}); dll.build = jest.fn().mockImplementation(() => new Promise(resolve => resolve())); describe('Dll manager', async () => { it('doesn\'t rewrite existing dll directory, throwing error message', async () => { fs.__setMockFiles({[dllPath]: ''}); await expect(dll.create({})).rejects.toMatch('Dll directory already exists'); }); it('builds dll-bundle during creation one', async () => { const packages = {packages: {package: 'version'}}; fs.__setMockFiles({}); await dll.create(packages); expect(dll.build).toHaveBeenCalledWith(packages); }); });