Skip to content

Commit

Permalink
test: Add test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Oct 3, 2021
1 parent 40d6cc2 commit cc93ae3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "create-kkt",
"version": "2.3.0",
"description": "Creates a KKT application using the command line.",
"homepage": "https://github.com/kktjs/create-kkt",
"homepage": "https://kktjs.github.io/create-kkt",
"author": "Kenny Wong <[email protected]> (https://github.com/jaywcjlove)",
"main": "lib/index.js",
"license": "MIT",
Expand Down
16 changes: 16 additions & 0 deletions test/cli.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/** @jest-environment node */
import { exampleHelp, run } from '../src/';

it('cliHelp test case', async () => {
expect(exampleHelp()).toBeUndefined();
// process.argv.push('-v');
// expect(await run()).toBeUndefined();
process.argv.push('--version');
expect(await run()).toBeUndefined();
});

it('version test case', async () => {
expect(exampleHelp()).toBeUndefined();
process.argv.push('-h');
expect(await run()).toBeUndefined();
});
21 changes: 21 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,24 @@ it('create project.', async () => {
expect(pkg.version).toEqual('1.0.0');
expect(Object.keys(pkg)).toEqual(expect.arrayContaining(['name', 'version']));
});

it('create project Option appName=undefined.', async () => {
jest.spyOn(process, 'exit').mockImplementation();
const opts: CreateOptions = {
_: [],
f: true,
force: true,
};
await create(opts, () => {});
});

it('create project Option path=undefined.', async () => {
jest.spyOn(process, 'exit').mockImplementation();
const opts: CreateOptions = {
_: ['my-app'],
f: true,
force: true,
appName: 'my-app',
};
await create(opts, () => {});
});

0 comments on commit cc93ae3

Please sign in to comment.