From ccfba4700ce8d4d1a3e571d2c353313227be0c0c Mon Sep 17 00:00:00 2001 From: Florian Weber Date: Sun, 28 Jul 2019 10:47:41 +0200 Subject: [PATCH] fix(cli): use init instead of core package on init command --- packages/cli/__mocks__/@averjs/core.js | 4 +--- packages/cli/__mocks__/@averjs/init.js | 9 +++++++++ packages/cli/__tests__/init.spec.js | 6 +++--- packages/cli/lib/commands/init.js | 6 +++--- 4 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 packages/cli/__mocks__/@averjs/init.js diff --git a/packages/cli/__mocks__/@averjs/core.js b/packages/cli/__mocks__/@averjs/core.js index a24716e53..0b53969ab 100644 --- a/packages/cli/__mocks__/@averjs/core.js +++ b/packages/cli/__mocks__/@averjs/core.js @@ -1,10 +1,8 @@ export const mockRun = jest.fn(); -export const mockInit = jest.fn(); const core = jest.fn().mockImplementation(() => { return { - run: mockRun, - init: mockInit + run: mockRun }; }); diff --git a/packages/cli/__mocks__/@averjs/init.js b/packages/cli/__mocks__/@averjs/init.js new file mode 100644 index 000000000..9fc26a48f --- /dev/null +++ b/packages/cli/__mocks__/@averjs/init.js @@ -0,0 +1,9 @@ +export const mockRun = jest.fn(); + +const init = jest.fn().mockImplementation(() => { + return { + run: mockRun + }; +}); + +export default init; diff --git a/packages/cli/__tests__/init.spec.js b/packages/cli/__tests__/init.spec.js index 4d778ccd9..93e964978 100644 --- a/packages/cli/__tests__/init.spec.js +++ b/packages/cli/__tests__/init.spec.js @@ -1,5 +1,5 @@ import AverCli from '../lib'; -import Core, { mockInit } from '../__mocks__/@averjs/core'; +import Init, { mockRun } from '../__mocks__/@averjs/init'; const OLD_ARGV = [ ...process.argv ]; let outputData = ''; @@ -24,9 +24,9 @@ test('run should execute core init', async() => { process.argv.push('init'); // eslint-disable-next-line no-unused-vars - const core = new Core(); + const init = new Init(); const cli = new AverCli(); await cli.run(); - expect(mockInit).toHaveBeenCalledTimes(1); + expect(mockRun).toHaveBeenCalledTimes(1); }); diff --git a/packages/cli/lib/commands/init.js b/packages/cli/lib/commands/init.js index c7b589fac..ff1d40c8a 100644 --- a/packages/cli/lib/commands/init.js +++ b/packages/cli/lib/commands/init.js @@ -1,5 +1,5 @@ import Command from './command'; -import Core from '@averjs/core'; +import Init from '@averjs/init'; export default class InitCommand extends Command { constructor() { @@ -10,7 +10,7 @@ export default class InitCommand extends Command { } run() { - const core = new Core(); - core.init(); + const init = new Init(); + init.run(); } }