@@ -9,6 +9,7 @@ let firebaseMock: FirebaseTools;
9
9
10
10
const FIREBASE_PROJECT = 'ikachu-aa3ef' ;
11
11
const PROJECT = 'pirojok-project' ;
12
+ const BUILD_TARGET = `${ PROJECT } :build:production` ;
12
13
13
14
describe ( 'Deploy Angular apps' , ( ) => {
14
15
beforeEach ( ( ) => initMocks ( ) ) ;
@@ -21,7 +22,7 @@ describe('Deploy Angular apps', () => {
21
22
22
23
it ( 'should invoke the builder' , async ( ) => {
23
24
const spy = spyOn ( context , 'scheduleTarget' ) . and . callThrough ( ) ;
24
- await deploy ( firebaseMock , context , 'host' , FIREBASE_PROJECT ) ;
25
+ await deploy ( firebaseMock , context , 'host' , BUILD_TARGET , FIREBASE_PROJECT ) ;
25
26
expect ( spy ) . toHaveBeenCalled ( ) ;
26
27
expect ( spy ) . toHaveBeenCalledWith ( {
27
28
target : 'build' ,
@@ -30,9 +31,17 @@ describe('Deploy Angular apps', () => {
30
31
} ) ;
31
32
} ) ;
32
33
34
+ it ( 'should allow the buildTarget to be specified' , async ( ) => {
35
+ const buildTarget = `${ PROJECT } :prerender` ;
36
+ const spy = spyOn ( context , 'scheduleTarget' ) . and . callThrough ( ) ;
37
+ await deploy ( firebaseMock , context , 'host' , buildTarget , FIREBASE_PROJECT ) ;
38
+ expect ( spy ) . toHaveBeenCalled ( ) ;
39
+ expect ( spy ) . toHaveBeenCalledWith ( { target : 'prerender' , project : PROJECT } ) ;
40
+ } ) ;
41
+
33
42
it ( 'should invoke firebase.deploy' , async ( ) => {
34
43
const spy = spyOn ( firebaseMock , 'deploy' ) . and . callThrough ( ) ;
35
- await deploy ( firebaseMock , context , 'host' , FIREBASE_PROJECT ) ;
44
+ await deploy ( firebaseMock , context , 'host' , BUILD_TARGET , FIREBASE_PROJECT ) ;
36
45
expect ( spy ) . toHaveBeenCalled ( ) ;
37
46
expect ( spy ) . toHaveBeenCalledWith ( {
38
47
cwd : 'host' , only : 'hosting:' + PROJECT
@@ -42,7 +51,7 @@ describe('Deploy Angular apps', () => {
42
51
describe ( 'error handling' , ( ) => {
43
52
it ( 'throws if there is no firebase project' , async ( ) => {
44
53
try {
45
- await deploy ( firebaseMock , context , 'host' )
54
+ await deploy ( firebaseMock , context , 'host' , BUILD_TARGET )
46
55
fail ( ) ;
47
56
} catch ( e ) {
48
57
expect ( e . message ) . toMatch ( / C a n n o t f i n d f i r e b a s e p r o j e c t / ) ;
@@ -52,7 +61,7 @@ describe('Deploy Angular apps', () => {
52
61
it ( 'throws if there is no target project' , async ( ) => {
53
62
context . target = undefined ;
54
63
try {
55
- await deploy ( firebaseMock , context , 'host' , FIREBASE_PROJECT )
64
+ await deploy ( firebaseMock , context , 'host' , BUILD_TARGET , FIREBASE_PROJECT )
56
65
fail ( ) ;
57
66
} catch ( e ) {
58
67
expect ( e . message ) . toMatch ( / C a n n o t e x e c u t e t h e b u i l d t a r g e t / ) ;
@@ -94,4 +103,4 @@ const initMocks = () => {
94
103
scheduleBuilder : ( _ : string , __ ?: JsonObject , ___ ?: ScheduleOptions ) => Promise . resolve ( { } as BuilderRun ) ,
95
104
scheduleTarget : ( _ : Target , __ ?: JsonObject , ___ ?: ScheduleOptions ) => Promise . resolve ( { } as BuilderRun )
96
105
} ;
97
- } ;
106
+ } ;
0 commit comments