@@ -92,8 +92,8 @@ describe('Guard Schematic', () => {
9292 expect ( fileString ) . not . toContain ( 'canLoad' ) ;
9393 } ) ;
9494
95- it ( 'should respect the guardType value' , async ( ) => {
96- const options = { ...defaultOptions , guardType : 'canActivate' } ;
95+ it ( 'should respect the functional guard value' , async ( ) => {
96+ const options = { ...defaultOptions , implements : [ 'CanActivate' ] , functional : true } ;
9797 const tree = await schematicRunner . runSchematicAsync ( 'guard' , options , appTree ) . toPromise ( ) ;
9898 const fileString = tree . readContent ( '/projects/bar/src/app/foo.guard.ts' ) ;
9999 expect ( fileString ) . toContain ( 'export const fooGuard: CanActivateFn = (route, state) => {' ) ;
@@ -104,7 +104,7 @@ describe('Guard Schematic', () => {
104104 } ) ;
105105
106106 it ( 'should generate a helper function to execute the guard in a test' , async ( ) => {
107- const options = { ...defaultOptions , guardType : 'canActivate' } ;
107+ const options = { ...defaultOptions , implements : [ 'CanActivate' ] , functional : true } ;
108108 const tree = await schematicRunner . runSchematicAsync ( 'guard' , options , appTree ) . toPromise ( ) ;
109109 const fileString = tree . readContent ( '/projects/bar/src/app/foo.guard.spec.ts' ) ;
110110 expect ( fileString ) . toContain ( 'const executeGuard: CanActivateFn = (...guardParameters) => ' ) ;
@@ -113,8 +113,8 @@ describe('Guard Schematic', () => {
113113 ) ;
114114 } ) ;
115115
116- it ( 'should generate CanDeactivateFn with unknown guardType ' , async ( ) => {
117- const options = { ...defaultOptions , guardType : 'canDeactivate' } ;
116+ it ( 'should generate CanDeactivateFn with unknown functional guard ' , async ( ) => {
117+ const options = { ...defaultOptions , implements : [ 'CanDeactivate' ] , functional : true } ;
118118 const tree = await schematicRunner . runSchematicAsync ( 'guard' , options , appTree ) . toPromise ( ) ;
119119 const fileString = tree . readContent ( '/projects/bar/src/app/foo.guard.ts' ) ;
120120 expect ( fileString ) . toContain (
@@ -157,8 +157,8 @@ describe('Guard Schematic', () => {
157157 expect ( fileString ) . toContain ( expectedImports ) ;
158158 } ) ;
159159
160- it ( 'should add correct imports based on canLoad guardType ' , async ( ) => {
161- const options = { ...defaultOptions , guardType : 'canLoad' } ;
160+ it ( 'should add correct imports based on canLoad functional guard ' , async ( ) => {
161+ const options = { ...defaultOptions , implements : [ 'CanLoad' ] , functional : true } ;
162162 const tree = await schematicRunner . runSchematicAsync ( 'guard' , options , appTree ) . toPromise ( ) ;
163163 const fileString = tree . readContent ( '/projects/bar/src/app/foo.guard.ts' ) ;
164164 const expectedImports = `import { CanLoadFn } from '@angular/router';` ;
@@ -176,8 +176,8 @@ describe('Guard Schematic', () => {
176176 expect ( fileString ) . toContain ( expectedImports ) ;
177177 } ) ;
178178
179- it ( 'should add correct imports based on canActivate guardType ' , async ( ) => {
180- const options = { ...defaultOptions , guardType : 'canActivate' } ;
179+ it ( 'should add correct imports based on canActivate functional guard ' , async ( ) => {
180+ const options = { ...defaultOptions , implements : [ 'CanActivate' ] , functional : true } ;
181181 const tree = await schematicRunner . runSchematicAsync ( 'guard' , options , appTree ) . toPromise ( ) ;
182182 const fileString = tree . readContent ( '/projects/bar/src/app/foo.guard.ts' ) ;
183183 const expectedImports = `import { CanActivateFn } from '@angular/router';` ;
0 commit comments