-
-
Notifications
You must be signed in to change notification settings - Fork 100
/
schematic.spec.ts
112 lines (100 loc) · 4.35 KB
/
schematic.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import { Tree } from '@angular-devkit/schematics';
import { createEmptyWorkspace } from '@nrwl/workspace/testing';
import { readJsonInTree } from '@nrwl/workspace';
import { AppType, STYLE_PLUGIN_DEPENDENCIES } from '../../utils/typings';
import { runSchematic, SUPPORTED_STYLE_LIBRARIES } from '../../utils/testing';
describe('schematic:ionic-app', () => {
let tree: Tree;
const options = { name: 'test', appTemplate: "Tabs"};
beforeEach(() => {
tree = createEmptyWorkspace(Tree.empty());
});
// TODO: Fix testsetu, add @nxtend/capacitor before run
xit('should run successfully', async () => {
await expect(
runSchematic('ionic-app', options, tree)
).resolves.not.toThrowError();
});
xit('should add Stencil/Ionic App dependencies', async () => {
const result = await runSchematic('ionic-app', options, tree);
const packageJson = readJsonInTree(result, 'package.json');
expect(packageJson.devDependencies['@stencil/core']).toBeDefined();
expect(packageJson.devDependencies['@ionic/core']).toBeDefined();
});
xit('should create files', async () => {
const appName = 'testapp';
const result = await runSchematic(
'ionic-app',
{ name: appName, appType: AppType.Application },
tree
);
const fileList = [
`apps/${appName}/stencil.config.ts`,
`apps/${appName}/tsconfig.json`,
`apps/${appName}/src/components/app-home/app-home.e2e.ts`,
`apps/${appName}/src/components/app-home/app-home.tsx`,
`apps/${appName}/src/components/app-home/app-home.css`,
`apps/${appName}/src/components/app-profile/app-profile.e2e.ts`,
`apps/${appName}/src/components/app-profile/app-profile.tsx`,
`apps/${appName}/src/components/app-profile/app-profile.spec.ts`,
`apps/${appName}/src/components/app-profile/app-profile.css`,
`apps/${appName}/src/components/app-root/app-root.e2e.ts`,
`apps/${appName}/src/components/app-root/app-root.tsx`,
`apps/${appName}/src/components/app-root/app-root.css`
];
fileList.forEach(file => expect(result.exists(file)))
});
xit('should create files in subdir', async () => {
const appName = 'testapp';
const result = await runSchematic(
'ionic-app',
{ name: appName, appType: AppType.Application, subdir: 'subdir' },
tree
);
const fileList = [
`apps/subdir/${appName}/stencil.config.ts`,
`apps/subdir/${appName}/tsconfig.json`,
`apps/subdir/${appName}/src/components/app-home/app-home.e2e.ts`,
`apps/subdir/${appName}/src/components/app-home/app-home.tsx`,
`apps/subdir/${appName}/src/components/app-home/app-home.css`,
`apps/subdir/${appName}/src/components/app-profile/app-profile.e2e.ts`,
`apps/subdir/${appName}/src/components/app-profile/app-profile.tsx`,
`apps/subdir/${appName}/src/components/app-profile/app-profile.spec.ts`,
`apps/subdir/${appName}/src/components/app-profile/app-profile.css`,
`apps/subdir/${appName}/src/components/app-root/app-root.e2e.ts`,
`apps/subdir/${appName}/src/components/app-root/app-root.tsx`,
`apps/subdir/${appName}/src/components/app-root/app-root.css`
];
fileList.forEach(file => expect(result.exists(file)))
});
xit('should add capacitor project', async () => {
const appName = 'testapp';
const result = await runSchematic(
'ionic-app',
{ name: appName, appType: AppType.Application },
tree
);
const fileList = [
`apps/${appName}/src/components/app-root/app-root.tsx`,
`apps/${appName}/src/components/app-profile/app-profile.tsx`,
`apps/${appName}/src/components/app-home/app-home.tsx`,
`apps/${appName}/src/components/app-tabs/app-tabs.tsx`
];
fileList.forEach(file => expect(result.exists(file)))
});
SUPPORTED_STYLE_LIBRARIES.forEach((style) => {
xit(`should add Stencil ${style} dependencies to ionic-app`, async () => {
const result = await runSchematic(
'ionic-app',
{ ...options, style: style },
tree
);
const packageJson = readJsonInTree(result, 'package.json');
expect(packageJson.devDependencies['@stencil/core']).toBeDefined();
const styleDependencies = STYLE_PLUGIN_DEPENDENCIES[style];
for (const devDependenciesKey in styleDependencies.devDependencies) {
expect(packageJson.devDependencies[devDependenciesKey]).toBeDefined();
}
});
});
});