Skip to content

Commit

Permalink
Added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Liza K committed Feb 17, 2020
1 parent 9d846ba commit 7f1c4a9
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions packages/kbn-plugin-generator/sao_template/sao.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ describe('plugin generator sao integration', () => {
const res = await sao.mockPrompt(template, {
generateApp: true,
generateApi: false,
generateScss: true,
});

// check output files
Expand All @@ -55,6 +56,7 @@ describe('plugin generator sao integration', () => {
expect(res.fileList).toContain('public/plugin.ts');
expect(res.fileList).toContain('public/types.ts');
expect(res.fileList).toContain('public/components/app.tsx');
expect(res.fileList).toContain('public/index.scss');
expect(res.fileList).not.toContain('server/index.ts');
});

Expand All @@ -72,6 +74,20 @@ describe('plugin generator sao integration', () => {
expect(res.fileList).toContain('server/routes/index.ts');
});

it('skips eslintrc and scss', async () => {
const res = await sao.mockPrompt(template, {
generateApp: true,
generateApi: true,
generateScss: false,
generateEslint: false,
});

// check output files
expect(res.fileList).toContain('public/plugin.ts');
expect(res.fileList).not.toContain('public/index.scss');
expect(res.fileList).not.toContain('.eslintrc.js');
});

it('plugin package has correct title', async () => {
const res = await sao.mockPrompt(template, {
generateApp: true,
Expand Down Expand Up @@ -121,5 +137,20 @@ describe('plugin generator sao integration', () => {
it('includes dotfiles', async () => {
const res = await sao.mockPrompt(template);
expect(res.files['.eslintrc.js']).toBeTruthy();
expect(res.files['.i18nrc.json']).toBeTruthy();
});

it('validaes path override', async () => {
try {
await sao.mockPrompt(template, {
generateApp: true,
generateApi: true,
generateScss: false,
generateEslint: false,
customPath: 'banana',
});
} catch (e) {
expect(e.message).toContain('Validation failed at prompt "customPath"');
}
});
});

0 comments on commit 7f1c4a9

Please sign in to comment.