forked from angular/components
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(schematics): constructor check rule does not check all diagn…
…ostics * Currently if the node of a diagnostic couldn't be resolved, or the `className` is not part of the upgrade data, we accidentally `return` instead of `continuing` the `for of` loop that checks every determined diagnostic. * Adds missing upgrade data for a V7 merged breaking change: angular#8286 * Renames the `test-cases/v5` directory to `test-cases/v6` because the test-cases are running against version target: `v6`. * Adds test cases for V7 constructor checks data; test cases for property name change from angular#8286
- Loading branch information
1 parent
18d0fa8
commit 04edb81
Showing
22 changed files
with
144 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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
38 changes: 38 additions & 0 deletions
38
src/lib/schematics/update/test-cases/v7-test-cases.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,38 @@ | ||
import {SchematicTestRunner} from '@angular-devkit/schematics/testing'; | ||
import {runPostScheduledTasks} from '../../test-setup/post-scheduled-tasks'; | ||
import {migrationCollection} from '../../test-setup/test-app'; | ||
import {createTestAppWithTestCase, readFileContent, resolveBazelDataFile} from './index.spec'; | ||
|
||
describe('v7 upgrade test cases', () => { | ||
|
||
/** | ||
* Name of test cases that will be used to verify that update schematics properly update | ||
* a developers application. | ||
*/ | ||
const testCases = [ | ||
'v7/property-names' | ||
]; | ||
|
||
// Iterates through every test case directory and generates a jasmine test block that will | ||
// verify that the update schematics properly update the test input to the expected output. | ||
testCases.forEach(testCaseName => { | ||
const inputPath = resolveBazelDataFile(`${testCaseName}_input.ts`); | ||
const expectedOutputPath = resolveBazelDataFile(`${testCaseName}_expected_output.ts`); | ||
|
||
it(`should apply update schematics to test case: ${testCaseName}`, () => { | ||
const runner = new SchematicTestRunner('schematics', migrationCollection); | ||
|
||
runner.runSchematic('migration-02', {}, createTestAppWithTestCase(inputPath)); | ||
|
||
// Run the scheduled TSLint fix task from the update schematic. This task is responsible for | ||
// identifying outdated code parts and performs the fixes. Since tasks won't run automatically | ||
// within a `SchematicTestRunner`, we manually need to run the scheduled task. | ||
return runPostScheduledTasks(runner, 'tslint-fix').toPromise().then(() => { | ||
expect(readFileContent('projects/material/src/main.ts')) | ||
.toBe(readFileContent(expectedOutputPath)); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
|
18 changes: 18 additions & 0 deletions
18
src/lib/schematics/update/test-cases/v7/property-names_expected_output.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,18 @@ | ||
import {EventEmitter, OnInit} from '@angular/core'; | ||
|
||
class SelectionModel { | ||
onChange = new EventEmitter<void>(); | ||
} | ||
|
||
/* Actual test case using the previously defined definitions. */ | ||
|
||
class A implements OnInit { | ||
self = {me: this}; | ||
|
||
constructor(private a: SelectionModel) {} | ||
|
||
ngOnInit() { | ||
this.a.changed.subscribe(() => console.log('Changed')); | ||
this.self.me.a.changed.subscribe(() => console.log('Changed 2')); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/lib/schematics/update/test-cases/v7/property-names_input.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,18 @@ | ||
import {EventEmitter, OnInit} from '@angular/core'; | ||
|
||
class SelectionModel { | ||
onChange = new EventEmitter<void>(); | ||
} | ||
|
||
/* Actual test case using the previously defined definitions. */ | ||
|
||
class A implements OnInit { | ||
self = {me: this}; | ||
|
||
constructor(private a: SelectionModel) {} | ||
|
||
ngOnInit() { | ||
this.a.onChange.subscribe(() => console.log('Changed')); | ||
this.self.me.a.onChange.subscribe(() => console.log('Changed 2')); | ||
} | ||
} |