@@ -9,6 +9,12 @@ beforeEach(() => {
99 parse = jest . fn ( )
1010} )
1111
12+ const invoke = ( options ) => {
13+ return ( ) => hook . apply ( { error : ( msg ) => { throw new Error ( msg ) } } , [ {
14+ ...options ,
15+ } ] )
16+ }
17+
1218test ( 'hook -- environmentId args with config' , async ( ) => {
1319 setStore ( {
1420 cloudmanager_environmentid : '4321' ,
@@ -32,15 +38,41 @@ test('hook -- environmentId args with config', async () => {
3238
3339 expect . assertions ( 2 )
3440
35- await hook ( {
41+ invoke ( {
3642 Command : FixtureWithEnvironmentIdArg ,
3743 argv : [ ] ,
38- } )
44+ } ) ( )
3945 new FixtureWithEnvironmentIdArg ( ) . parse ( FixtureWithEnvironmentIdArg , [ ] )
4046 expect ( parse . mock . calls . length ) . toEqual ( 2 )
4147 expect ( parse . mock . calls [ 1 ] [ 1 ] ) . toEqual ( [ '4321' ] )
4248} )
4349
50+ test ( 'hook -- bad configuration' , async ( ) => {
51+ setStore ( {
52+ cloudmanager_environmentid : '4321' ,
53+ 'ims.contexts.aio-cli-plugin-cloudmanager' : {
54+ client_id : 'test-client-id' ,
55+ client_secret : '5678' ,
56+ ims_org_id : 'someorg@AdobeOrg' ,
57+ technical_account_id :
'[email protected] ' , 58+ technical_account_email : 'unused' ,
59+ meta_scopes : [
60+ 'ent_adobeio_sdk' ,
61+ 'ent_cloudmgr_sdk' ,
62+ ] ,
63+ } ,
64+ } )
65+
66+ parse = jest . fn ( ) . mockImplementationOnce ( ( ) => true )
67+
68+ expect . assertions ( 1 )
69+
70+ expect ( invoke ( {
71+ Command : FixtureWithEnvironmentIdArg ,
72+ argv : [ ] ,
73+ } ) ) . toThrowError ( 'One or more of the required fields in ims.contexts.aio-cli-plugin-cloudmanager were not set. Missing keys were private_key.' )
74+ } )
75+
4476const thisPlugin = {
4577 name : '@adobe/aio-cli-plugin-cloudmanager' ,
4678}
0 commit comments