Skip to content

Commit

Permalink
move cli tests to cli folder.
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Mar 1, 2023
1 parent 8e0b3fe commit 652f1db
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions test/cli/cli.spec.mts → cli/cli.spec.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import Environment from 'yeoman-environment';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
import { mock, resetAllMocks, fn } from '@node-loaders/jest-mock';
import { basicHelpers as helpers, createBlueprintFiles } from '../support/index.mjs';
import { basicHelpers as helpers, createBlueprintFiles } from '../test/support/index.mjs';

import { getCommand as actualGetCommonand } from '../../cli/utils.mjs';
import { createProgram } from '../../cli/program.mjs';
import { getCommand as actualGetCommonand } from './utils.mjs';
import { createProgram } from './program.mjs';

const { logger, getCommand } = await mock<typeof import('../../cli/utils.mjs')>('../../cli/utils.mjs');
const { buildJHipster } = await import('../../cli/program.mjs');
const { logger, getCommand } = await mock<typeof import('./utils.mjs')>('./utils.mjs');
const { buildJHipster } = await import('./program.mjs');

const __filename = fileURLToPath(import.meta.url);
const jhipsterCli = join(dirname(__filename), '..', '..', 'bin', 'jhipster.mjs');
const jhipsterCli = join(dirname(__filename), '..', 'bin', 'jhipster.mjs');

const mockCli = async (argv: string[], opts = {}) => {
const program = await buildJHipster({ printLogo: () => {}, ...opts, program: createProgram(), loadCommand: key => opts[`./${key}`] });
Expand Down Expand Up @@ -159,7 +159,7 @@ describe('cli', () => {
beforeEach(async () => {
getCommand.mockImplementation(actualGetCommonand);

const BaseGenerator = (await import('../../generators/base/index.mjs')).default;
const BaseGenerator = (await import('../generators/base/index.mjs')).default;
env = Environment.createEnv();
generator = new (helpers.createDummyGenerator(BaseGenerator))({ env, namespace: 'jhipster:foo' });
generator._options = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import assert from 'assert';
import { expect } from 'chai';
import fs from 'fs';
import sinon from 'sinon';
import { basicHelpers as helpers, createBlueprintFiles } from '../support/index.mjs';
import { basicHelpers as helpers, createBlueprintFiles } from '../test/support/index.mjs';

import EnvironmentBuilder from '../../cli/environment-builder.mjs';
import EnvironmentBuilder from './environment-builder.mjs';

const cliBlueprintFiles = {
'cli/commands.js': `export default {
Expand Down
4 changes: 2 additions & 2 deletions test/cli/program.spec.mts → cli/program.spec.mts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import { expect } from 'chai';

import { createProgram } from '../../cli/program.mjs';
import { defaultHelpers as helpers } from '../support/index.mjs';
import { createProgram } from './program.mjs';
import { defaultHelpers as helpers } from '../test/support/index.mjs';

describe('cli - program', () => {
beforeEach(async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/cli/cli-utils.spec.mts → cli/utils.spec.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import { getCommand } from '../../cli/utils.mjs';
import { getCommand } from './utils.mjs';

describe('cli - utils test', () => {
describe('getCommand', () => {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@
"prettier:check": "prettier --check \"{,**/}*.{js,ts,cjs,mjs,cts,mts,json,md,yml,java,xml}\"",
"prettier:format": "prettier --write \"{,**/}*.{js,ts,cjs,mjs,cts,mts,json,md,yml,java,xml}\"",
"pretest": "npm run lint",
"test": "npm run mocha-test generators",
"test": "npm run mocha-test generators cli",
"update-snapshot": "mocha --no-insight --no-parallel --updateSnapshot --",
"update-snapshots": "mocha test generators --require test/mocha-update-snapshots.config.cjs --no-insight --forbid-only",
"update-snapshots": "mocha test generators cli --require test/mocha-update-snapshots.config.cjs --no-insight --forbid-only",
"watch": "concurrently \"tsc --watch\" \"node ./watch.mjs\""
},
"dependencies": {
Expand Down

0 comments on commit 652f1db

Please sign in to comment.