Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(module:notification): remove deprecated APIs for v10
BREAKING CHANGES: - `NzNotificationDataFilled` has been removed, use `NzNotificationRef` instead. - `NzNotificationDataOptions.nzPosition` has been removed, use `NzNotificationDataOptions.nzPlacement` instead.
- Loading branch information
Showing
5 changed files
with
88 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,16 @@ | ||
|
||
import { PropertyNameUpgradeData, VersionChanges } from '@angular/cdk/schematics'; | ||
import { PropertyNameUpgradeData, TargetVersion, VersionChanges } from '@angular/cdk/schematics'; | ||
|
||
export const propertyNames: VersionChanges<PropertyNameUpgradeData> = {}; | ||
export const propertyNames: VersionChanges<PropertyNameUpgradeData> = { | ||
[TargetVersion.V10]: [{ | ||
pr: '', | ||
changes: [ | ||
{ | ||
replace: 'nzPosition', | ||
replaceWith: 'nzPlacement', | ||
whitelist: {classes: ['NzNotificationDataOptions']} | ||
} | ||
] | ||
} | ||
] | ||
}; |
67 changes: 67 additions & 0 deletions
67
schematics/ng-update/test-cases/v10/notification-deprecated.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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)`); | ||
}); | ||
|
||
}); | ||
|
||
}); |