@@ -5,13 +5,53 @@ import * as mock from "../../mock/common.mock.json";
55
66import messages , { $t } from "../../../../src/messages" ;
77import { getDeveloperHubUrl } from "../../../../src/util/inquirer" ;
8+ // import { join } from "path";
89
910const region : { cma : string ; cda : string ; name : string } =
1011 configHandler . get ( "region" ) ;
1112const developerHubBaseUrl = getDeveloperHubUrl ( ) ;
1213
1314describe ( "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" , ( ) => {
1555 test
1656 . stdout ( { print : process . env . PRINT === "true" || false } )
1757 . stub ( ux . action , "stop" , ( ) => { } )
@@ -33,21 +73,31 @@ describe("app:deploy", () => {
3373 )
3474 . nock ( `https://${ developerHubBaseUrl } ` , ( api ) =>
3575 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+ )
4181 . nock ( `https://${ developerHubBaseUrl } ` , ( api ) =>
4282 api . put ( `/manifests/${ mock . apps2 [ 1 ] . uid } ` ) . reply ( 200 , mock . deploy_custom_host )
4383 )
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+ ] )
4595 . do ( ( { stdout } ) => {
4696 expect ( stdout ) . to . contain (
4797 $t ( messages . APP_DEPLOYED , { app : mock . apps [ 1 ] . name } )
4898 ) ;
4999 } )
50- . it ( "should deploy the app with custom hosting" ) ;
100+ . it ( "should deploy the app with custom hosting using flags in command " ) ;
51101 } ) ;
52102
53103 describe ( "Deploy an app with Hosting with Launch with existing project" , ( ) => {
0 commit comments