Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(material/schematics): initial setup for v15 ng-update (#25102)
- Loading branch information
1 parent
ef4a360
commit 8b14771
Showing
3 changed files
with
60 additions
and
0 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
13 changes: 13 additions & 0 deletions
13
src/material/schematics/ng-update/migrations/legacy-components-v15/index.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,13 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import {Migration, TargetVersion} from '@angular/cdk/schematics'; | ||
|
||
export class LegacyComponentsMigration extends Migration<null> { | ||
enabled = this.targetVersion === TargetVersion.V15; | ||
} |
45 changes: 45 additions & 0 deletions
45
src/material/schematics/ng-update/test-cases/v15/legacy-components-v15.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,45 @@ | ||
import {UnitTestTree} from '@angular-devkit/schematics/testing'; | ||
import {createTestCaseSetup} from '@angular/cdk/schematics/testing'; | ||
import {join} from 'path'; | ||
import {MIGRATION_PATH} from '../../../paths'; | ||
|
||
const PROJECT_ROOT_DIR = '/projects/cdk-testing'; | ||
const THEME_FILE_PATH = join(PROJECT_ROOT_DIR, 'src/theme.scss'); | ||
const TS_FILE_PATH = join(PROJECT_ROOT_DIR, 'src/app/app.component.ts'); | ||
|
||
describe('v15 legacy components migration', () => { | ||
let tree: UnitTestTree; | ||
|
||
/** Writes an array of lines as a single file. */ | ||
let writeLines: (path: string, lines: string[]) => void; | ||
|
||
/** Reads a file and split it into an array where each item is a new line. */ | ||
let splitFile: (path: string) => string[]; | ||
|
||
/** Runs the v15 migration on the test application. */ | ||
let runMigration: () => Promise<{logOutput: string}>; | ||
|
||
beforeEach(async () => { | ||
const testSetup = await createTestCaseSetup('migration-v15', MIGRATION_PATH, []); | ||
tree = testSetup.appTree; | ||
runMigration = testSetup.runFixers; | ||
splitFile = (path: string) => tree.readContent(path).split('\n'); | ||
writeLines = (path: string, lines: string[]) => testSetup.writeFile(path, lines.join('\n')); | ||
}); | ||
|
||
describe('typescript migrations', () => { | ||
it('should do nothing yet', async () => { | ||
writeLines(TS_FILE_PATH, [' ']); | ||
await runMigration(); | ||
expect(splitFile(TS_FILE_PATH)).toEqual([' ']); | ||
}); | ||
}); | ||
|
||
describe('style migrations', () => { | ||
it('should do nothing yet', async () => { | ||
writeLines(THEME_FILE_PATH, [' ']); | ||
await runMigration(); | ||
expect(splitFile(THEME_FILE_PATH)).toEqual([' ']); | ||
}); | ||
}); | ||
}); |