6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
9
- import * as Architect from '@angular-devkit/architect' ;
9
+ import { BuilderContext } from '@angular-devkit/architect' ;
10
10
import { BrowserBuilderOptions } from '@angular-devkit/build-angular' ;
11
11
import { logging } from '@angular-devkit/core' ;
12
12
import * as fs from 'fs' ;
@@ -28,18 +28,17 @@ describe('Prerender Builder Utils', () => {
28
28
{ path : '/user/:id' } ,
29
29
] ;
30
30
31
+ const TSCONFIG_PATH = 'tsconfig.app.json' ;
31
32
const CONTEXT = {
32
33
workspaceRoot : '/path/to/angular/json' ,
33
- getTargetOptions : ( ) => ( { tsConfig : 'tsconfig.app.json' } ) ,
34
34
logger : new logging . NullLogger ( ) ,
35
- } as unknown as Architect . BuilderContext ;
35
+ } as unknown as BuilderContext ;
36
36
37
37
let parseAngularRoutesSpy : jasmine . Spy ;
38
38
let loggerErrorSpy : jasmine . Spy ;
39
39
40
40
beforeEach ( ( ) => {
41
41
spyOn ( fs , 'readFileSync' ) . and . returnValue ( ROUTES_FILE_CONTENT ) ;
42
- spyOn ( Architect , 'targetFromTargetString' ) . and . returnValue ( { } as Architect . Target ) ;
43
42
parseAngularRoutesSpy = spyOn ( guessParser , 'parseAngularRoutes' )
44
43
. and . returnValue ( GUESSED_ROUTES ) ;
45
44
loggerErrorSpy = spyOn ( CONTEXT . logger , 'error' ) ;
@@ -51,7 +50,7 @@ describe('Prerender Builder Utils', () => {
51
50
routesFile : ROUTES_FILE ,
52
51
guessRoutes : true ,
53
52
} as PrerenderBuilderOptions ;
54
- const routes = await getRoutes ( options , CONTEXT ) ;
53
+ const routes = await getRoutes ( options , TSCONFIG_PATH , CONTEXT ) ;
55
54
expect ( routes ) . toEqual (
56
55
jasmine . arrayContaining ( [
57
56
'/route1' ,
@@ -65,7 +64,7 @@ describe('Prerender Builder Utils', () => {
65
64
66
65
it ( 'Should return only the given routes' , async ( ) => {
67
66
const options = { routes : ROUTES } as PrerenderBuilderOptions ;
68
- const routes = await getRoutes ( options , CONTEXT ) ;
67
+ const routes = await getRoutes ( options , TSCONFIG_PATH , CONTEXT ) ;
69
68
expect ( routes ) . toEqual ( jasmine . arrayContaining ( [
70
69
'/route3' ,
71
70
'/route4' ,
@@ -74,7 +73,7 @@ describe('Prerender Builder Utils', () => {
74
73
75
74
it ( 'Should return the routes from the routesFile' , async ( ) => {
76
75
const options = { routesFile : ROUTES_FILE } as PrerenderBuilderOptions ;
77
- const routes = await getRoutes ( options , CONTEXT ) ;
76
+ const routes = await getRoutes ( options , TSCONFIG_PATH , CONTEXT ) ;
78
77
expect ( routes ) . toEqual ( jasmine . arrayContaining ( [
79
78
'/route1' ,
80
79
'/route2' ,
@@ -85,7 +84,7 @@ describe('Prerender Builder Utils', () => {
85
84
it ( 'Should catch errors thrown by parseAngularRoutes' , async ( ) => {
86
85
const options = { routes : ROUTES , guessRoutes : true } as PrerenderBuilderOptions ;
87
86
parseAngularRoutesSpy . and . throwError ( 'Test Error' ) ;
88
- const routes = await getRoutes ( options , CONTEXT ) ;
87
+ const routes = await getRoutes ( options , TSCONFIG_PATH , CONTEXT ) ;
89
88
expect ( routes ) . toEqual ( jasmine . arrayContaining ( [
90
89
'/route3' ,
91
90
'/route4' ,
0 commit comments