From 7f1c4a9c947f93d2078f4379e66be85e0cf54e7f Mon Sep 17 00:00:00 2001 From: Liza K Date: Mon, 17 Feb 2020 10:45:54 +0200 Subject: [PATCH] Added more tests --- .../sao_template/sao.test.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/packages/kbn-plugin-generator/sao_template/sao.test.js b/packages/kbn-plugin-generator/sao_template/sao.test.js index 2e869d653379a..03d95e12d58da 100755 --- a/packages/kbn-plugin-generator/sao_template/sao.test.js +++ b/packages/kbn-plugin-generator/sao_template/sao.test.js @@ -47,6 +47,7 @@ describe('plugin generator sao integration', () => { const res = await sao.mockPrompt(template, { generateApp: true, generateApi: false, + generateScss: true, }); // check output files @@ -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'); }); @@ -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, @@ -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"'); + } }); });