Skip to content

Commit

Permalink
Add unit test for generator to keep 100% coverage (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
kristw authored and zhaoyongjie committed Nov 26, 2021
1 parent df7a49c commit f389bd2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = class extends Generator {
type: 'list',
name: 'language',
message: 'Choose language',
default: 'typescript',
choices: [
{
name: 'typescript',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('generator-superset:app', () => {
});

it('creates files', () => {
assert.file(['package.json', 'README.md', 'src/index.js', 'test/index.test.js']);
assert.file(['package.json', 'README.md', 'src/index.ts', 'test/index.test.ts']);
});

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,32 @@ describe('generator-superset:package', () => {

beforeAll(() => {
dir = process.cwd();
});

describe('typescript', () => {
beforeAll(() =>
helpers
.run(path.join(__dirname, '../generators/package'))
.withPrompts({ name: 'my-package', language: 'typescript' })
.withOptions({ skipInstall: true }),
);

return helpers
.run(path.join(__dirname, '../generators/package'))
.withPrompts({ name: 'my-package' })
.withOptions({ skipInstall: true });
it('creates files', () => {
assert.file(['package.json', 'README.md', 'src/index.ts', 'test/index.test.ts']);
});
});

it('creates files', () => {
assert.file(['package.json', 'README.md', 'src/index.js', 'test/index.test.js']);
describe('javascript', () => {
beforeAll(() =>
helpers
.run(path.join(__dirname, '../generators/package'))
.withPrompts({ name: 'my-package', language: 'javascript' })
.withOptions({ skipInstall: true }),
);

it('creates files', () => {
assert.file(['package.json', 'README.md', 'src/index.js', 'test/index.test.js']);
});
});

/*
Expand Down

0 comments on commit f389bd2

Please sign in to comment.