@@ -85,8 +85,8 @@ describe('Guard Schematic', () => {
85
85
expect ( fileString ) . toContain ( 'canActivate' ) ;
86
86
expect ( fileString ) . not . toContain ( 'CanActivateChild' ) ;
87
87
expect ( fileString ) . not . toContain ( 'canActivateChild' ) ;
88
- expect ( fileString ) . not . toContain ( 'CanLoad ' ) ;
89
- expect ( fileString ) . not . toContain ( 'canLoad ' ) ;
88
+ expect ( fileString ) . not . toContain ( 'CanMatch ' ) ;
89
+ expect ( fileString ) . not . toContain ( 'canMatch ' ) ;
90
90
} ) ;
91
91
92
92
it ( 'should respect the functional guard value' , async ( ) => {
@@ -96,8 +96,8 @@ describe('Guard Schematic', () => {
96
96
expect ( fileString ) . toContain ( 'export const fooGuard: CanActivateFn = (route, state) => {' ) ;
97
97
expect ( fileString ) . not . toContain ( 'CanActivateChild' ) ;
98
98
expect ( fileString ) . not . toContain ( 'canActivateChild' ) ;
99
- expect ( fileString ) . not . toContain ( 'CanLoad ' ) ;
100
- expect ( fileString ) . not . toContain ( 'canLoad ' ) ;
99
+ expect ( fileString ) . not . toContain ( 'CanMatch ' ) ;
100
+ expect ( fileString ) . not . toContain ( 'canMatch ' ) ;
101
101
} ) ;
102
102
103
103
it ( 'should generate a helper function to execute the guard in a test' , async ( ) => {
@@ -121,7 +121,7 @@ describe('Guard Schematic', () => {
121
121
} ) ;
122
122
123
123
it ( 'should respect the implements values' , async ( ) => {
124
- const implementationOptions = [ 'CanActivate' , 'CanLoad ' , 'CanActivateChild' ] ;
124
+ const implementationOptions = [ 'CanActivate' , 'CanDeactivate ' , 'CanActivateChild' ] ;
125
125
const options = { ...defaultOptions , implements : implementationOptions } ;
126
126
const tree = await schematicRunner . runSchematic ( 'guard' , options , appTree ) ;
127
127
const fileString = tree . readContent ( '/projects/bar/src/app/foo.guard.ts' ) ;
@@ -134,16 +134,6 @@ describe('Guard Schematic', () => {
134
134
} ) ;
135
135
} ) ;
136
136
137
- it ( 'should add correct imports based on CanLoad implementation' , async ( ) => {
138
- const implementationOptions = [ 'CanLoad' ] ;
139
- const options = { ...defaultOptions , implements : implementationOptions } ;
140
- const tree = await schematicRunner . runSchematic ( 'guard' , options , appTree ) ;
141
- const fileString = tree . readContent ( '/projects/bar/src/app/foo.guard.ts' ) ;
142
- const expectedImports = `import { CanLoad, Route, UrlSegment, UrlTree } from '@angular/router';` ;
143
-
144
- expect ( fileString ) . toContain ( expectedImports ) ;
145
- } ) ;
146
-
147
137
it ( 'should add correct imports based on CanMatch implementation' , async ( ) => {
148
138
const implementationOptions = [ 'CanMatch' ] ;
149
139
const options = { ...defaultOptions , implements : implementationOptions } ;
@@ -154,15 +144,6 @@ describe('Guard Schematic', () => {
154
144
expect ( fileString ) . toContain ( expectedImports ) ;
155
145
} ) ;
156
146
157
- it ( 'should add correct imports based on canLoad functional guard' , async ( ) => {
158
- const options = { ...defaultOptions , implements : [ 'CanLoad' ] , functional : true } ;
159
- const tree = await schematicRunner . runSchematic ( 'guard' , options , appTree ) ;
160
- const fileString = tree . readContent ( '/projects/bar/src/app/foo.guard.ts' ) ;
161
- const expectedImports = `import { CanLoadFn } from '@angular/router';` ;
162
-
163
- expect ( fileString ) . toContain ( expectedImports ) ;
164
- } ) ;
165
-
166
147
it ( 'should add correct imports based on CanActivate implementation' , async ( ) => {
167
148
const implementationOptions = [ 'CanActivate' ] ;
168
149
const options = { ...defaultOptions , implements : implementationOptions } ;
@@ -183,13 +164,13 @@ describe('Guard Schematic', () => {
183
164
} ) ;
184
165
185
166
it ( 'should add correct imports if multiple implementations was selected' , async ( ) => {
186
- const implementationOptions = [ 'CanActivate' , 'CanLoad ' , 'CanActivateChild' ] ;
167
+ const implementationOptions = [ 'CanActivate' , 'CanMatch ' , 'CanActivateChild' ] ;
187
168
const options = { ...defaultOptions , implements : implementationOptions } ;
188
169
const tree = await schematicRunner . runSchematic ( 'guard' , options , appTree ) ;
189
170
const fileString = tree . readContent ( '/projects/bar/src/app/foo.guard.ts' ) ;
190
171
const expectedImports =
191
172
`import ` +
192
- `{ ActivatedRouteSnapshot, CanActivate, CanActivateChild, CanLoad , Route, RouterStateSnapshot, UrlSegment, UrlTree } ` +
173
+ `{ ActivatedRouteSnapshot, CanActivate, CanActivateChild, CanMatch , Route, RouterStateSnapshot, UrlSegment, UrlTree } ` +
193
174
`from '@angular/router';` ;
194
175
195
176
expect ( fileString ) . toContain ( expectedImports ) ;
0 commit comments