Skip to content

Commit b8cc020

Browse files
committed
🧪 test: add test case for path parameter
1 parent 8dc9abc commit b8cc020

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

src/commands/generate/component/common/common.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,24 @@ describe('Commands: [Generate] => [Component] => [Common]', () => {
2626
filesystem.remove(`${name}`);
2727
});
2828

29+
test('should generate a common component on provided path', async () => {
30+
const name = 'sample-with-path';
31+
const baseFolder = 'sample-app';
32+
const path = `${baseFolder}/src/app/components`;
33+
34+
await runNgxdCLI(`g c c ${name} --path ${path}`);
35+
36+
const html = filesystem.read(`${path}/${name}/${name}.component.html`);
37+
const scss = filesystem.read(`${path}/${name}/${name}.component.scss`);
38+
const ts = filesystem.read(`${path}/${name}/${name}.component.ts`);
39+
40+
expect(html).toBeDefined();
41+
expect(scss).toBeDefined();
42+
expect(ts).toBeDefined();
43+
44+
filesystem.remove(baseFolder);
45+
});
46+
2947
test('should generate a common component html with default template <p>sample works</p>', async () => {
3048
const name = 'sample-with-default-template';
3149

src/commands/generate/component/dialog/dialog.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,24 @@ describe('Commands: [Generate] => [Component] => [Dialog]', () => {
2727
expect(ts).toBeDefined();
2828
});
2929

30+
test('should generate a dialog component on provided path', async () => {
31+
const name = 'sample-with-path';
32+
const baseFolder = 'sample-app';
33+
const path = `${baseFolder}/src/app/components`;
34+
35+
await runNgxdCLI(`g c d ${name} --path ${path}`);
36+
37+
const html = filesystem.read(`${path}/${name}/${name}.dialog.html`);
38+
const scss = filesystem.read(`${path}/${name}/${name}.dialog.scss`);
39+
const ts = filesystem.read(`${path}/${name}/${name}.dialog.ts`);
40+
41+
expect(html).toBeDefined();
42+
expect(scss).toBeDefined();
43+
expect(ts).toBeDefined();
44+
45+
// filesystem.remove(baseFolder);
46+
});
47+
3048
test('should generate a dialog component html with default template <p>sample works</p>', async () => {
3149
await runNgxdCLI(`g c d ${name}`);
3250
const html = filesystem.read(`${name}/${name}.dialog.html`);

src/commands/generate/component/page/page.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,24 @@ describe('Commands: [Generate] => [Component] => [Page]', () => {
2727
expect(ts).toBeDefined();
2828
});
2929

30+
test('should generate a page component on provided path', async () => {
31+
const name = 'sample-with-path';
32+
const baseFolder = 'sample-app';
33+
const path = `${baseFolder}/src/app/components`;
34+
35+
await runNgxdCLI(`g c p ${name} --path ${path}`);
36+
37+
const html = filesystem.read(`${path}/${name}/${name}.page.html`);
38+
const scss = filesystem.read(`${path}/${name}/${name}.page.scss`);
39+
const ts = filesystem.read(`${path}/${name}/${name}.page.ts`);
40+
41+
expect(html).toBeDefined();
42+
expect(scss).toBeDefined();
43+
expect(ts).toBeDefined();
44+
45+
filesystem.remove(baseFolder);
46+
});
47+
3048
test('should generate a page component html with default template <p>sample works</p>', async () => {
3149
await runNgxdCLI(`g c p ${name}`);
3250
const html = filesystem.read(`${name}/${name}.page.html`);

0 commit comments

Comments
 (0)