@@ -9,14 +9,15 @@ let firebaseMock: FirebaseTools;
99
1010const FIREBASE_PROJECT = 'ikachu-aa3ef' ;
1111const PROJECT = 'pirojok-project' ;
12+ const BUILD_TARGET = `${ PROJECT } :build:production` ;
1213
1314describe ( 'Deploy Angular apps' , ( ) => {
1415 beforeEach ( ( ) => initMocks ( ) ) ;
1516
1617 it ( 'should check if the user is authenticated by invoking list' , async ( ) => {
1718 const spy = spyOn ( firebaseMock , 'list' ) ;
1819 const spyLogin = spyOn ( firebaseMock , 'login' ) ;
19- await deploy ( firebaseMock , context , 'host' , FIREBASE_PROJECT ) ;
20+ await deploy ( firebaseMock , context , 'host' , BUILD_TARGET , FIREBASE_PROJECT ) ;
2021 expect ( spy ) . toHaveBeenCalled ( ) ;
2122 expect ( spyLogin ) . not . toHaveBeenCalled ( ) ;
2223 } ) ;
@@ -25,14 +26,14 @@ describe('Deploy Angular apps', () => {
2526 firebaseMock . list = ( ) => Promise . reject ( ) ;
2627 const spy = spyOn ( firebaseMock , 'list' ) . and . callThrough ( ) ;
2728 const spyLogin = spyOn ( firebaseMock , 'login' ) ;
28- await deploy ( firebaseMock , context , 'host' , FIREBASE_PROJECT ) ;
29+ await deploy ( firebaseMock , context , 'host' , BUILD_TARGET , FIREBASE_PROJECT ) ;
2930 expect ( spy ) . toHaveBeenCalled ( ) ;
3031 expect ( spyLogin ) . toHaveBeenCalled ( ) ;
3132 } ) ;
3233
3334 it ( 'should invoke the builder' , async ( ) => {
3435 const spy = spyOn ( context , 'scheduleTarget' ) . and . callThrough ( ) ;
35- await deploy ( firebaseMock , context , 'host' , FIREBASE_PROJECT ) ;
36+ await deploy ( firebaseMock , context , 'host' , BUILD_TARGET , FIREBASE_PROJECT ) ;
3637 expect ( spy ) . toHaveBeenCalled ( ) ;
3738 expect ( spy ) . toHaveBeenCalledWith ( {
3839 target : 'build' ,
@@ -41,9 +42,17 @@ describe('Deploy Angular apps', () => {
4142 } ) ;
4243 } ) ;
4344
45+ it ( 'should allow the buildTarget to be specified' , async ( ) => {
46+ const buildTarget = `${ PROJECT } :prerender` ;
47+ const spy = spyOn ( context , 'scheduleTarget' ) . and . callThrough ( ) ;
48+ await deploy ( firebaseMock , context , 'host' , buildTarget , FIREBASE_PROJECT ) ;
49+ expect ( spy ) . toHaveBeenCalled ( ) ;
50+ expect ( spy ) . toHaveBeenCalledWith ( { target : 'prerender' , project : PROJECT } ) ;
51+ } ) ;
52+
4453 it ( 'should invoke firebase.deploy' , async ( ) => {
4554 const spy = spyOn ( firebaseMock , 'deploy' ) . and . callThrough ( ) ;
46- await deploy ( firebaseMock , context , 'host' , FIREBASE_PROJECT ) ;
55+ await deploy ( firebaseMock , context , 'host' , BUILD_TARGET , FIREBASE_PROJECT ) ;
4756 expect ( spy ) . toHaveBeenCalled ( ) ;
4857 expect ( spy ) . toHaveBeenCalledWith ( {
4958 cwd : 'host' , only : 'hosting:' + PROJECT
@@ -53,7 +62,7 @@ describe('Deploy Angular apps', () => {
5362 describe ( 'error handling' , ( ) => {
5463 it ( 'throws if there is no firebase project' , async ( ) => {
5564 try {
56- await deploy ( firebaseMock , context , 'host' )
65+ await deploy ( firebaseMock , context , 'host' , BUILD_TARGET )
5766 fail ( ) ;
5867 } catch ( e ) {
5968 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 / ) ;
@@ -63,7 +72,7 @@ describe('Deploy Angular apps', () => {
6372 it ( 'throws if there is no target project' , async ( ) => {
6473 context . target = undefined ;
6574 try {
66- await deploy ( firebaseMock , context , 'host' , FIREBASE_PROJECT )
75+ await deploy ( firebaseMock , context , 'host' , BUILD_TARGET , FIREBASE_PROJECT )
6776 fail ( ) ;
6877 } catch ( e ) {
6978 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 / ) ;
@@ -103,4 +112,4 @@ const initMocks = () => {
103112 scheduleBuilder : ( _ : string , __ ?: JsonObject , ___ ?: ScheduleOptions ) => Promise . resolve ( { } as BuilderRun ) ,
104113 scheduleTarget : ( _ : Target , __ ?: JsonObject , ___ ?: ScheduleOptions ) => Promise . resolve ( { } as BuilderRun )
105114 } ;
106- } ;
115+ } ;
0 commit comments