Skip to content

Commit

Permalink
fix(cli): use init instead of core package on init command
Browse files Browse the repository at this point in the history
  • Loading branch information
exreplay committed Jul 28, 2019
1 parent 2ec0d05 commit ccfba47
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
4 changes: 1 addition & 3 deletions packages/cli/__mocks__/@averjs/core.js
Original file line number Diff line number Diff line change
@@ -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
};
});

Expand Down
9 changes: 9 additions & 0 deletions packages/cli/__mocks__/@averjs/init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const mockRun = jest.fn();

const init = jest.fn().mockImplementation(() => {
return {
run: mockRun
};
});

export default init;
6 changes: 3 additions & 3 deletions packages/cli/__tests__/init.spec.js
Original file line number Diff line number Diff line change
@@ -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 = '';
Expand All @@ -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);
});
6 changes: 3 additions & 3 deletions packages/cli/lib/commands/init.js
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -10,7 +10,7 @@ export default class InitCommand extends Command {
}

run() {
const core = new Core();
core.init();
const init = new Init();
init.run();
}
}

0 comments on commit ccfba47

Please sign in to comment.