@@ -92,8 +92,8 @@ describe('Guard Schematic', () => {
92
92
expect ( fileString ) . not . toContain ( 'canLoad' ) ;
93
93
} ) ;
94
94
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 } ;
97
97
const tree = await schematicRunner . runSchematicAsync ( 'guard' , options , appTree ) . toPromise ( ) ;
98
98
const fileString = tree . readContent ( '/projects/bar/src/app/foo.guard.ts' ) ;
99
99
expect ( fileString ) . toContain ( 'export const fooGuard: CanActivateFn = (route, state) => {' ) ;
@@ -104,7 +104,7 @@ describe('Guard Schematic', () => {
104
104
} ) ;
105
105
106
106
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 } ;
108
108
const tree = await schematicRunner . runSchematicAsync ( 'guard' , options , appTree ) . toPromise ( ) ;
109
109
const fileString = tree . readContent ( '/projects/bar/src/app/foo.guard.spec.ts' ) ;
110
110
expect ( fileString ) . toContain ( 'const executeGuard: CanActivateFn = (...guardParameters) => ' ) ;
@@ -113,8 +113,8 @@ describe('Guard Schematic', () => {
113
113
) ;
114
114
} ) ;
115
115
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 } ;
118
118
const tree = await schematicRunner . runSchematicAsync ( 'guard' , options , appTree ) . toPromise ( ) ;
119
119
const fileString = tree . readContent ( '/projects/bar/src/app/foo.guard.ts' ) ;
120
120
expect ( fileString ) . toContain (
@@ -157,8 +157,8 @@ describe('Guard Schematic', () => {
157
157
expect ( fileString ) . toContain ( expectedImports ) ;
158
158
} ) ;
159
159
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 } ;
162
162
const tree = await schematicRunner . runSchematicAsync ( 'guard' , options , appTree ) . toPromise ( ) ;
163
163
const fileString = tree . readContent ( '/projects/bar/src/app/foo.guard.ts' ) ;
164
164
const expectedImports = `import { CanLoadFn } from '@angular/router';` ;
@@ -176,8 +176,8 @@ describe('Guard Schematic', () => {
176
176
expect ( fileString ) . toContain ( expectedImports ) ;
177
177
} ) ;
178
178
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 } ;
181
181
const tree = await schematicRunner . runSchematicAsync ( 'guard' , options , appTree ) . toPromise ( ) ;
182
182
const fileString = tree . readContent ( '/projects/bar/src/app/foo.guard.ts' ) ;
183
183
const expectedImports = `import { CanActivateFn } from '@angular/router';` ;
0 commit comments