@@ -5,13 +5,53 @@ import * as mock from "../../mock/common.mock.json";
5
5
6
6
import messages , { $t } from "../../../../src/messages" ;
7
7
import { getDeveloperHubUrl } from "../../../../src/util/inquirer" ;
8
+ // import { join } from "path";
8
9
9
10
const region : { cma : string ; cda : string ; name : string } =
10
11
configHandler . get ( "region" ) ;
11
12
const developerHubBaseUrl = getDeveloperHubUrl ( ) ;
12
13
13
14
describe ( "app:deploy" , ( ) => {
14
- describe ( "Deploy an app with custom hosting" , ( ) => {
15
+ describe ( "Deploy an app with custom hosting" , ( ) => {
16
+ test
17
+ . stdout ( { print : process . env . PRINT === "true" || false } )
18
+ . stub ( ux . action , "stop" , ( ) => { } )
19
+ . stub ( ux . action , "start" , ( ) => { } )
20
+ . stub ( cliux , "inquire" , async ( ...args : any ) => {
21
+ const [ prompt ] : any = args ;
22
+ const cases = {
23
+ App : mock . apps [ 1 ] . name ,
24
+ Organization : mock . organizations [ 0 ] . name ,
25
+ "hosting types" : "Custom Hosting" ,
26
+ appUrl : "https://example.com" ,
27
+ } ;
28
+ return ( cases as Record < string , any > ) [ prompt . name ] ;
29
+ } )
30
+ . nock ( region . cma , ( api ) =>
31
+ api
32
+ . get ( "/v3/organizations?limit=100&asc=name&include_count=true&skip=0" )
33
+ . reply ( 200 , { organizations : mock . organizations } )
34
+ )
35
+ . nock ( `https://${ developerHubBaseUrl } ` , ( api ) =>
36
+ api
37
+ . get ( "/manifests?limit=50&asc=name&include_count=true&skip=0" )
38
+ . reply ( 200 , {
39
+ data : mock . apps2 ,
40
+ } )
41
+ )
42
+ . nock ( `https://${ developerHubBaseUrl } ` , ( api ) =>
43
+ api . put ( `/manifests/${ mock . apps2 [ 1 ] . uid } ` ) . reply ( 200 , mock . deploy_custom_host )
44
+ )
45
+ . command ( [ "app:deploy" ] )
46
+ . do ( ( { stdout } ) => {
47
+ expect ( stdout ) . to . contain (
48
+ $t ( messages . APP_DEPLOYED , { app : mock . apps [ 1 ] . name } )
49
+ ) ;
50
+ } )
51
+ . it ( "should deploy the app with custom hosting" ) ;
52
+ } ) ;
53
+
54
+ describe ( "Deploy an app with custom hosting using flags in command" , ( ) => {
15
55
test
16
56
. stdout ( { print : process . env . PRINT === "true" || false } )
17
57
. stub ( ux . action , "stop" , ( ) => { } )
@@ -33,21 +73,31 @@ describe("app:deploy", () => {
33
73
)
34
74
. nock ( `https://${ developerHubBaseUrl } ` , ( api ) =>
35
75
api
36
- . get ( " /manifests?limit=50&asc=name&include_count=true&skip=0" )
37
- . reply ( 200 , {
38
- data : mock . apps2 ,
39
- } )
40
- )
76
+ . get ( ` /manifests/ ${ mock . apps2 [ 1 ] . uid } ` )
77
+ . reply ( 200 , {
78
+ data : mock . apps2 [ 1 ] ,
79
+ } )
80
+ )
41
81
. nock ( `https://${ developerHubBaseUrl } ` , ( api ) =>
42
82
api . put ( `/manifests/${ mock . apps2 [ 1 ] . uid } ` ) . reply ( 200 , mock . deploy_custom_host )
43
83
)
44
- . command ( [ "app:deploy" ] )
84
+ . command ( [
85
+ "app:deploy" ,
86
+ "--org" ,
87
+ mock . organizations [ 0 ] . uid ,
88
+ "--app-uid" ,
89
+ mock . apps [ 1 ] . uid ,
90
+ "--hosting-type" ,
91
+ "Custom Hosting" ,
92
+ "--app-url" ,
93
+ "https://example.com" ,
94
+ ] )
45
95
. do ( ( { stdout } ) => {
46
96
expect ( stdout ) . to . contain (
47
97
$t ( messages . APP_DEPLOYED , { app : mock . apps [ 1 ] . name } )
48
98
) ;
49
99
} )
50
- . it ( "should deploy the app with custom hosting" ) ;
100
+ . it ( "should deploy the app with custom hosting using flags in command " ) ;
51
101
} ) ;
52
102
53
103
describe ( "Deploy an app with Hosting with Launch with existing project" , ( ) => {
0 commit comments