-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
notification-deprecated.spec.ts
67 lines (51 loc) · 2.09 KB
/
notification-deprecated.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
import { getSystemPath, normalize, virtualFs } from '@angular-devkit/core';
import { TempScopedNodeJsSyncHost } from '@angular-devkit/core/node/testing';
import { HostTree } from '@angular-devkit/schematics';
import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
import * as shx from 'shelljs';
import { SchematicsTestNGConfig, SchematicsTestTsConfig } from '../config';
describe('upload migration', () => {
let runner: SchematicTestRunner;
let host: TempScopedNodeJsSyncHost;
let tree: UnitTestTree;
let tmpDirPath: string;
let previousWorkingDir: string;
beforeEach(() => {
runner = new SchematicTestRunner('test', require.resolve('../../../migration.json'));
host = new TempScopedNodeJsSyncHost();
tree = new UnitTestTree(new HostTree(host));
writeFile('/tsconfig.json', JSON.stringify(SchematicsTestTsConfig));
writeFile('/angular.json', JSON.stringify(SchematicsTestNGConfig));
previousWorkingDir = shx.pwd();
tmpDirPath = getSystemPath(host.root);
shx.cd(tmpDirPath);
writeFakeAngular();
});
afterEach(() => {
shx.cd(previousWorkingDir);
shx.rm('-r', tmpDirPath);
});
function writeFakeAngular(): void { writeFile('/node_modules/@angular/core/index.d.ts', ``); }
function writeFile(filePath: string, contents: string): void {
host.sync.write(normalize(filePath), virtualFs.stringToFileBuffer(contents));
}
// tslint:disable-next-line:no-any
async function runMigration(): Promise<any> {
await runner.runSchematicAsync('migration-v10', {}, tree).toPromise();
}
describe('Property names', () => {
it('should replace deprecated property names', async() => {
writeFile('/index.ts', `
export interface NzNotificationDataOptions {
nzPlacement?: any;
nzPosition?: any;
}
const option: NzNotificationDataOptions = {};
console.log(option.nzPosition);`);
await runMigration();
const content = tree.readContent('/index.ts');
expect(content).toContain(`console.log(option.nzPlacement)`);
expect(content).not.toContain(`console.log(option.nzPosition)`);
});
});
});