@@ -6,20 +6,24 @@ import {
6
6
Target
7
7
} from '@angular-devkit/architect/src' ;
8
8
import { JsonObject , logging } from '@angular-devkit/core' ;
9
+ import { BuildTarget } from 'interfaces' ;
9
10
10
11
import deploy from './actions' ;
11
12
12
13
let context : BuilderContext ;
13
14
const mockEngine = { run : ( _ : string , __ : any , __2 : any ) => Promise . resolve ( ) } ;
14
15
15
16
const PROJECT = 'pirojok-project' ;
17
+ const BUILD_TARGET : BuildTarget = {
18
+ name : `${ PROJECT } :build:production`
19
+ } ;
16
20
17
21
describe ( 'Deploy Angular apps' , ( ) => {
18
22
beforeEach ( ( ) => initMocks ( ) ) ;
19
23
20
24
it ( 'should invoke the builder' , async ( ) => {
21
25
const spy = spyOn ( context , 'scheduleTarget' ) . and . callThrough ( ) ;
22
- await deploy ( mockEngine , context , 'host' , { } ) ;
26
+ await deploy ( mockEngine , context , BUILD_TARGET , { } ) ;
23
27
24
28
expect ( spy ) . toHaveBeenCalledWith (
25
29
{
@@ -33,7 +37,7 @@ describe('Deploy Angular apps', () => {
33
37
34
38
it ( 'should invoke the builder with the baseHref' , async ( ) => {
35
39
const spy = spyOn ( context , 'scheduleTarget' ) . and . callThrough ( ) ;
36
- await deploy ( mockEngine , context , 'host' , { baseHref : '/folder' } ) ;
40
+ await deploy ( mockEngine , context , BUILD_TARGET , { baseHref : '/folder' } ) ;
37
41
38
42
expect ( spy ) . toHaveBeenCalledWith (
39
43
{
@@ -47,16 +51,16 @@ describe('Deploy Angular apps', () => {
47
51
48
52
it ( 'should invoke engine.run' , async ( ) => {
49
53
const spy = spyOn ( mockEngine , 'run' ) . and . callThrough ( ) ;
50
- await deploy ( mockEngine , context , 'host' , { } ) ;
54
+ await deploy ( mockEngine , context , BUILD_TARGET , { } ) ;
51
55
52
- expect ( spy ) . toHaveBeenCalledWith ( 'host ' , { } , context . logger ) ;
56
+ expect ( spy ) . toHaveBeenCalledWith ( 'dist/some-folder ' , { } , context . logger ) ;
53
57
} ) ;
54
58
55
59
describe ( 'error handling' , ( ) => {
56
60
it ( 'throws if there is no target project' , async ( ) => {
57
61
context . target = undefined ;
58
62
try {
59
- await deploy ( mockEngine , context , 'host' , { } ) ;
63
+ await deploy ( mockEngine , context , BUILD_TARGET , { } ) ;
60
64
fail ( ) ;
61
65
} catch ( e ) {
62
66
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 / ) ;
@@ -73,7 +77,7 @@ describe('Deploy Angular apps', () => {
73
77
result : Promise . resolve ( createBuilderOutputMock ( false ) )
74
78
} as BuilderRun ) ;
75
79
try {
76
- await deploy ( mockEngine , context , 'host' , { } ) ;
80
+ await deploy ( mockEngine , context , BUILD_TARGET , { } ) ;
77
81
fail ( ) ;
78
82
} catch ( e ) {
79
83
expect ( e . message ) . toEqual ( 'Error while building the app.' ) ;
@@ -102,7 +106,10 @@ const initMocks = () => {
102
106
validateOptions : _ => Promise . resolve ( { } as any ) ,
103
107
getBuilderNameForTarget : ( ) => Promise . resolve ( '' ) ,
104
108
analytics : null as any ,
105
- getTargetOptions : ( _ : Target ) => Promise . resolve ( { } ) ,
109
+ getTargetOptions : ( _ : Target ) =>
110
+ Promise . resolve ( {
111
+ outputPath : 'dist/some-folder'
112
+ } ) ,
106
113
reportProgress : ( _ : number , __ ?: number , ___ ?: string ) => { } ,
107
114
reportStatus : ( _ : string ) => { } ,
108
115
reportRunning : ( ) => { } ,
0 commit comments