Skip to content

Commit

Permalink
test: update test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Apr 5, 2023
1 parent 8dda73f commit 548576e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
26 changes: 15 additions & 11 deletions test/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ console.log = jest.fn();

const argv = process.argv.slice(0, 2);

it('create project. 1', async () => {
process.argv = argv;
process.argv.push('my-app2');
process.argv.push('-f');
process.argv.push('--output');
process.argv.push('test');
// console.log(process.argv)
await import('../src/cli');
// console.log(path.resolve(__dirname, 'my-app2'))
expect(await fs.existsSync(path.resolve(__dirname, 'my-app2'))).toBeTruthy();
await fs.remove('test/my-app2');
describe('create project. 1', () => {
const tempPath = path.resolve(__dirname, 'my-app2');
beforeAll(async () => {
process.argv = argv;
process.argv.push('my-app2');
process.argv.push('-f');
process.argv.push('--output');
process.argv.push('test');
await fs.ensureDir(tempPath);
await import('../src/cli');
});

test('create project. 1', async () => {
expect(await fs.existsSync(tempPath)).toBeTruthy();
});
});
6 changes: 3 additions & 3 deletions test/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ it('create project. options => force/example', async () => {
await create(opts, '');
expect(mockExit).toHaveBeenCalledWith(1);
mockExit.mockRestore();
});
}, 3000);

it('create project. options => force', async () => {
await fs.ensureDir('test/my-app');
Expand All @@ -70,7 +70,7 @@ it('create project. options => force', async () => {
).toBeTruthy();
expect(mockExit).toHaveBeenCalledWith(1);
mockExit.mockRestore();
});
}, 6000);

it('create project. options => example', async () => {
const opts: CreateOptions = {
Expand All @@ -84,4 +84,4 @@ it('create project. options => example', async () => {
// @ts-ignore
expect(console.log.mock.calls[0][0].indexOf('Success! Created') > -1).toBeTruthy();
await fs.remove('test/my-app');
});
}, 8000);

0 comments on commit 548576e

Please sign in to comment.