From f389bd2fb5dd82d2ab4581b47bba9a09dcbd517f Mon Sep 17 00:00:00 2001 From: Krist Wongsuphasawat Date: Mon, 4 Feb 2019 15:43:44 -0800 Subject: [PATCH] Add unit test for generator to keep 100% coverage (#89) --- .../generators/package/index.js | 1 + .../generator-superset/test/app.test.js | 2 +- .../generator-superset/test/package.test.js | 29 +++++++++++++++---- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/package/index.js b/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/package/index.js index b12547471d9b9..1d29848028110 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/package/index.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/generators/package/index.js @@ -18,6 +18,7 @@ module.exports = class extends Generator { type: 'list', name: 'language', message: 'Choose language', + default: 'typescript', choices: [ { name: 'typescript', diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/test/app.test.js b/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/test/app.test.js index 957be64901176..96548e85d3d64 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/test/app.test.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/test/app.test.js @@ -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']); }); /* diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/test/package.test.js b/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/test/package.test.js index 6f3423a41d7c7..f7117c56b866c 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/test/package.test.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/generator-superset/test/package.test.js @@ -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']); + }); }); /*