/
index.spec.ts
55 lines (49 loc) · 1.74 KB
/
index.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
import { Tree } from '@angular-devkit/schematics';
import { Schema } from '../application/schema';
import { stringUtils, setTest, jsonParse, IHelperSchema } from '@nstudio/xplat';
import {
createXplatWithApps,
getFileContent,
createXplatWithNativeScriptWeb
} from '@nstudio/xplat/testing';
import { runSchematic } from '../../utils/testing';
setTest();
describe('helpers schematic', () => {
let appTree: Tree;
beforeEach(() => {
appTree = Tree.empty();
appTree = createXplatWithNativeScriptWeb(appTree);
});
it('imports: should create all files', async () => {
const options: IHelperSchema = {
name: 'imports'
};
// console.log('appTree:', appTree);
const tree = await runSchematic('helpers', options, appTree);
const files = tree.files;
// console.log(files);
// xplat helpers
expect(
tree.exists('/xplat/nativescript/utils/@nativescript/core.ts')
).toBeTruthy();
expect(
files.indexOf('/xplat/nativescript/utils/@nativescript/ui.ts')
).toBeGreaterThanOrEqual(0);
expect(
files.indexOf('/xplat/nativescript/utils/@nativescript/angular/core.ts')
).toBeGreaterThanOrEqual(0);
// should update tsconfig files
let filePath = '/tsconfig.json';
let fileContent = jsonParse(getFileContent(tree, filePath));
// console.log(fileContent);
expect(fileContent.compilerOptions.paths['@nativescript/*'][0]).toBe(
'xplat/nativescript/utils/@nativescript/*'
);
filePath = '/apps/nativescript-viewer/tsconfig.json';
fileContent = jsonParse(getFileContent(tree, filePath));
// console.log(fileContent);
expect(fileContent.compilerOptions.paths['@nativescript/*'][0]).toBe(
'../../xplat/nativescript/utils/@nativescript/*'
);
});
});