File tree Expand file tree Collapse file tree 2 files changed +46
-4
lines changed
Expand file tree Collapse file tree 2 files changed +46
-4
lines changed Original file line number Diff line number Diff line change @@ -13,14 +13,14 @@ test('with empty param object', async () => {
1313} )
1414
1515test ( 'it parses positional parameters' , async ( ) => {
16- expect ( parseParams ( 'foo' ) ) . toHaveProperty ( '_' , [ 'foo' ] )
16+ expect ( parseParams ( 'foo bar baz ' ) ) . toHaveProperty ( '_' , [ 'foo' , 'bar' , 'baz '] )
1717} )
1818
1919test ( 'it parses arguments using the default settings of library' , async ( ) => {
20- const parsed = parseParams ( '--foo bar --env.foo=bar' )
20+ const parsed = parseParams ( '--foo bar --env.foo=bar baz ' )
2121 expect ( parsed ) . toHaveProperty ( 'foo' , 'bar' )
2222 expect ( parsed ) . toHaveProperty ( 'env' , { foo : 'bar' } )
23- expect ( parsed ) . toHaveProperty ( '_' , [ ] )
23+ expect ( parsed ) . toHaveProperty ( '_' , [ 'baz' ] )
2424} )
2525
2626test ( 'it works with empty string' , async ( ) => {
Original file line number Diff line number Diff line change @@ -1069,9 +1069,51 @@ test('stores params and parsed params into context', async () => {
10691069 }
10701070 const data = expect . objectContaining ( {
10711071 auto_merge : true ,
1072+ ref : 'test-ref' ,
1073+ environment : 'production' ,
1074+ owner : 'corp' ,
1075+ repo : 'test' ,
1076+ production_environment : true ,
1077+ required_contexts : [ ] ,
10721078 payload : expect . objectContaining ( {
10731079 params,
1074- parsed_params
1080+ parsed_params,
1081+ sha : null ,
1082+ type : 'branch-deploy'
1083+ } )
1084+ } )
1085+ expect ( await run ( ) ) . toBe ( 'success' )
1086+ expect ( createDeploymentMock ) . toHaveBeenCalledWith ( data )
1087+ expect ( setOutputMock ) . toHaveBeenCalledWith ( 'params' , params )
1088+ expect ( setOutputMock ) . toHaveBeenCalledWith ( 'parsed_params' , parsed_params )
1089+ } )
1090+
1091+ test ( 'stores params and parsed params into context with complex params' , async ( ) => {
1092+ github . context . payload . comment . body =
1093+ '.deploy | something1 --foo=bar --env.development=false --env.production=true'
1094+ const params =
1095+ 'something1 --foo=bar --env.development=false --env.production=true'
1096+ const parsed_params = {
1097+ _ : [ 'something1' ] ,
1098+ foo : 'bar' ,
1099+ env : {
1100+ development : 'false' ,
1101+ production : 'true'
1102+ }
1103+ }
1104+ const data = expect . objectContaining ( {
1105+ auto_merge : true ,
1106+ ref : 'test-ref' ,
1107+ environment : 'production' ,
1108+ owner : 'corp' ,
1109+ repo : 'test' ,
1110+ production_environment : true ,
1111+ required_contexts : [ ] ,
1112+ payload : expect . objectContaining ( {
1113+ params,
1114+ parsed_params,
1115+ sha : null ,
1116+ type : 'branch-deploy'
10751117 } )
10761118 } )
10771119 expect ( await run ( ) ) . toBe ( 'success' )
You can’t perform that action at this time.
0 commit comments