@@ -9,14 +9,15 @@ 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 ( ) ) ;
15
16
16
17
it ( 'should check if the user is authenticated by invoking list' , async ( ) => {
17
18
const spy = spyOn ( firebaseMock , 'list' ) ;
18
19
const spyLogin = spyOn ( firebaseMock , 'login' ) ;
19
- await deploy ( firebaseMock , context , 'host' , FIREBASE_PROJECT ) ;
20
+ await deploy ( firebaseMock , context , 'host' , BUILD_TARGET , FIREBASE_PROJECT ) ;
20
21
expect ( spy ) . toHaveBeenCalled ( ) ;
21
22
expect ( spyLogin ) . not . toHaveBeenCalled ( ) ;
22
23
} ) ;
@@ -25,14 +26,14 @@ describe('Deploy Angular apps', () => {
25
26
firebaseMock . list = ( ) => Promise . reject ( ) ;
26
27
const spy = spyOn ( firebaseMock , 'list' ) . and . callThrough ( ) ;
27
28
const spyLogin = spyOn ( firebaseMock , 'login' ) ;
28
- await deploy ( firebaseMock , context , 'host' , FIREBASE_PROJECT ) ;
29
+ await deploy ( firebaseMock , context , 'host' , BUILD_TARGET , FIREBASE_PROJECT ) ;
29
30
expect ( spy ) . toHaveBeenCalled ( ) ;
30
31
expect ( spyLogin ) . toHaveBeenCalled ( ) ;
31
32
} ) ;
32
33
33
34
it ( 'should invoke the builder' , async ( ) => {
34
35
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 ) ;
36
37
expect ( spy ) . toHaveBeenCalled ( ) ;
37
38
expect ( spy ) . toHaveBeenCalledWith ( {
38
39
target : 'build' ,
@@ -41,9 +42,17 @@ describe('Deploy Angular apps', () => {
41
42
} ) ;
42
43
} ) ;
43
44
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
+
44
53
it ( 'should invoke firebase.deploy' , async ( ) => {
45
54
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 ) ;
47
56
expect ( spy ) . toHaveBeenCalled ( ) ;
48
57
expect ( spy ) . toHaveBeenCalledWith ( {
49
58
cwd : 'host' , only : 'hosting:' + PROJECT
@@ -53,7 +62,7 @@ describe('Deploy Angular apps', () => {
53
62
describe ( 'error handling' , ( ) => {
54
63
it ( 'throws if there is no firebase project' , async ( ) => {
55
64
try {
56
- await deploy ( firebaseMock , context , 'host' )
65
+ await deploy ( firebaseMock , context , 'host' , BUILD_TARGET )
57
66
fail ( ) ;
58
67
} catch ( e ) {
59
68
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', () => {
63
72
it ( 'throws if there is no target project' , async ( ) => {
64
73
context . target = undefined ;
65
74
try {
66
- await deploy ( firebaseMock , context , 'host' , FIREBASE_PROJECT )
75
+ await deploy ( firebaseMock , context , 'host' , BUILD_TARGET , FIREBASE_PROJECT )
67
76
fail ( ) ;
68
77
} catch ( e ) {
69
78
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 = () => {
103
112
scheduleBuilder : ( _ : string , __ ?: JsonObject , ___ ?: ScheduleOptions ) => Promise . resolve ( { } as BuilderRun ) ,
104
113
scheduleTarget : ( _ : Target , __ ?: JsonObject , ___ ?: ScheduleOptions ) => Promise . resolve ( { } as BuilderRun )
105
114
} ;
106
- } ;
115
+ } ;
0 commit comments