forked from angular/angular-cli
-
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.
fix(@schematics/angular): add CanDeactivate guard
This generates a generic `CanDeactivate<unknown>` guard. Fixes angular#15668
- Loading branch information
Showing
4 changed files
with
28 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,7 @@ | |
"enum": [ | ||
"CanActivate", | ||
"CanActivateChild", | ||
"CanDeactivate", | ||
"CanLoad" | ||
], | ||
"type": "string" | ||
|
16 changes: 16 additions & 0 deletions
16
tests/legacy-cli/e2e/tests/generate/guard/guard-multiple-implements.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,16 @@ | ||
import {join} from 'path'; | ||
import {ng} from '../../../utils/process'; | ||
import {expectFileToExist,expectFileToMatch} from '../../../utils/fs'; | ||
|
||
|
||
export default async function() { | ||
// Does not create a sub directory. | ||
const guardDir = join('src', 'app'); | ||
|
||
await ng('generate', 'guard', 'load', '--implements=CanLoad', '--implements=CanDeactivate'); | ||
await expectFileToExist(guardDir); | ||
await expectFileToExist(join(guardDir, 'load.guard.ts')); | ||
await expectFileToMatch(join(guardDir, 'load.guard.ts'), /implements CanLoad, CanDeactivate<unknown>/); | ||
await expectFileToExist(join(guardDir, 'load.guard.spec.ts')); | ||
await ng('test', '--watch=false'); | ||
} |