|
| 1 | +import { ProjectType } from '@nrwl/workspace'; |
| 2 | +import { |
| 3 | + checkFilesExist, |
| 4 | + ensureNxProject, |
| 5 | + readJson, |
| 6 | + runNxCommandAsync, |
| 7 | + uniq, |
| 8 | +} from '@nrwl/nx-plugin/testing'; |
| 9 | +import { SUPPORTED_STYLE_LIBRARIES } from '../../../libs/stencil/src/utils/testing'; |
| 10 | +import { testProject } from '../utils/testing'; |
| 11 | + |
| 12 | +describe('e2e', () => { |
| 13 | + describe('generate with style', () => { |
| 14 | + describe('stencil app', () => { |
| 15 | + for (var style of ['css', 'scss', 'less', 'styl', 'pcss']) { |
| 16 | + it(`should create app with ${style}`, async (done) => { |
| 17 | + const plugin = uniq('app2'); |
| 18 | + |
| 19 | + ensureNxProject('@nxext/stencil', 'dist/libs/stencil'); |
| 20 | + await runNxCommandAsync( |
| 21 | + `generate @nxext/stencil:app ${plugin} --style=${style}` |
| 22 | + ); |
| 23 | + |
| 24 | + testProject(plugin, style, ProjectType.Application); |
| 25 | + |
| 26 | + done(); |
| 27 | + }); |
| 28 | + } |
| 29 | + }); |
| 30 | + |
| 31 | + describe('--directory', () => { |
| 32 | + it('should create src in the specified directory', async (done) => { |
| 33 | + const plugin = uniq('app1'); |
| 34 | + ensureNxProject('@nxext/stencil', 'dist/libs/stencil'); |
| 35 | + await runNxCommandAsync( |
| 36 | + `generate @nxext/stencil:application ${plugin} --directory subdir --style=css` |
| 37 | + ); |
| 38 | + expect(() => |
| 39 | + checkFilesExist(`apps/subdir/${plugin}/stencil.config.ts`) |
| 40 | + ).not.toThrow(); |
| 41 | + done(); |
| 42 | + }); |
| 43 | + }); |
| 44 | + |
| 45 | + describe('--tags', () => { |
| 46 | + it('should add tags to nx.json', async (done) => { |
| 47 | + const plugin = uniq('app3'); |
| 48 | + ensureNxProject('@nxext/stencil', 'dist/libs/stencil'); |
| 49 | + await runNxCommandAsync( |
| 50 | + `generate @nxext/stencil:app ${plugin} --tags e2etag,e2ePackage --style=css` |
| 51 | + ); |
| 52 | + const nxJson = readJson('nx.json'); |
| 53 | + expect(nxJson.projects[plugin].tags).toEqual(['e2etag', 'e2ePackage']); |
| 54 | + done(); |
| 55 | + }); |
| 56 | + }); |
| 57 | + |
| 58 | + describe('stencil app builder', () => { |
| 59 | + SUPPORTED_STYLE_LIBRARIES.forEach(style => { |
| 60 | + it(`should build app with ${style}`, async (done) => { |
| 61 | + const plugin = uniq('app2'); |
| 62 | + ensureNxProject('@nxext/stencil', 'dist/libs/stencil'); |
| 63 | + await runNxCommandAsync( |
| 64 | + `generate @nxext/stencil:app ${plugin} --style=css` |
| 65 | + ); |
| 66 | + |
| 67 | + const result = await runNxCommandAsync(`build ${plugin}`); |
| 68 | + expect(result.stdout).toContain('build finished'); |
| 69 | + |
| 70 | + done(); |
| 71 | + }); |
| 72 | + }); |
| 73 | + }); |
| 74 | + }); |
| 75 | +}); |
0 commit comments