This repository was archived by the owner on May 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex_spec.ts
More file actions
106 lines (86 loc) · 4.63 KB
/
index_spec.ts
File metadata and controls
106 lines (86 loc) · 4.63 KB
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
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
import { Schema as WorkspaceOptions } from '@schematics/angular/workspace/schema';
import * as path from 'path';
import { latestVersions } from '../utility/latest-versions';
const collectionPath = path.join(__dirname, '../collection.json');
describe('install', () => {
// TODO: Extract workspase preparing somewhere
const appOptions: any = {
name: 'testApp',
projectRoot: '',
inlineStyle: false,
inlineTemplate: false,
routing: true,
style: 'css',
skipTests: false,
skipPackageJson: false
};
const workspaceOptions: WorkspaceOptions = {
name: 'workspace',
// TODO: use angular latest-versions module
version: '6.0.0'
};
const angularSchematicsCollection = require.resolve('../../node_modules/@schematics/angular/collection.json');
const schematicRunner = new SchematicTestRunner('@schematics/angular', angularSchematicsCollection);
let appTree: UnitTestTree;
beforeEach(async () => {
appTree = await schematicRunner.runSchematicAsync('workspace', workspaceOptions).toPromise();
appTree = await schematicRunner.runSchematicAsync('application', appOptions, appTree).toPromise();
});
it('should add devextreme dependency (default)', async () => {
const runner = new SchematicTestRunner('schematics', collectionPath);
const tree = await runner.runSchematicAsync('install', {}, appTree).toPromise();
const packageConfig = JSON.parse(tree.readContent('package.json'));
expect(packageConfig.dependencies['devextreme']).toBe(latestVersions['devextreme']);
expect(packageConfig.dependencies['devextreme-angular']).toBe(latestVersions['devextreme-angular']);
expect(packageConfig.devDependencies['devextreme-themebuilder']).toBe(latestVersions['devextreme']);
});
it('should add devextreme dependency (custom)', async () => {
const runner = new SchematicTestRunner('schematics', collectionPath);
const tree = await runner.runSchematicAsync('install', { dxversion: '18.2.5' }, appTree).toPromise();
const packageConfig = JSON.parse(tree.readContent('package.json'));
expect(packageConfig.dependencies.devextreme).toBe('18.2.5');
expect(packageConfig.devDependencies['devextreme-themebuilder']).toBe('18.2.5');
});
it('should add devextreme cli devDependency', async () => {
const runner = new SchematicTestRunner('schematics', collectionPath);
const tree = await runner.runSchematicAsync('install', { dxversion: '18.2.5' }, appTree).toPromise();
const packageConfig = JSON.parse(tree.readContent('package.json'));
expect(packageConfig.devDependencies['devextreme-cli']).toBeDefined();
});
it('should add devextreme styles', async () => {
const runner = new SchematicTestRunner('schematics', collectionPath);
const tree = await runner.runSchematicAsync('install', {}, appTree).toPromise();
const angularConfig = JSON.parse(tree.readContent('angular.json'));
const styles = angularConfig['projects']['testApp']['architect']['build']['options']['styles'];
expect(styles[0]).toBe('node_modules/devextreme/dist/css/dx.common.css');
expect(styles[1]).toBe('node_modules/devextreme/dist/css/dx.light.css');
});
it('should register jszip', async () => {
const runner = new SchematicTestRunner('schematics', collectionPath);
const tree = await runner.runSchematicAsync('install', {}, appTree).toPromise();
const tsconfig = JSON.parse(tree.readContent('tsconfig.json'));
const jszip = tsconfig['compilerOptions']['paths']['jszip'];
expect(jszip[0]).toBe('node_modules/jszip/dist/jszip.min.js');
});
it('should add devextreme styles to the specified project', async () => {
const secondAppOptions: any = {
name: 'testApp2',
inlineStyle: false,
inlineTemplate: false,
projectRoot: 'src2',
routing: true,
style: 'css',
skipTests: false,
skipPackageJson: false
};
appTree = await schematicRunner.runSchematicAsync('application', secondAppOptions, appTree).toPromise();
const runner = new SchematicTestRunner('schematics', collectionPath);
const tree = await runner.runSchematicAsync('install', { project: 'testApp2' }, appTree).toPromise();
const angularConfig = JSON.parse(tree.readContent('angular.json'));
const styles = angularConfig['projects']['testApp2']['architect']['build']['options']['styles'];
expect(styles[0]).toBe('node_modules/devextreme/dist/css/dx.common.css');
expect(styles[1]).toBe('node_modules/devextreme/dist/css/dx.light.css');
expect(angularConfig['projects']['testApp']['architect']['build']['options']['styles'].length).toBe(1);
});
});