@@ -68,6 +68,16 @@ describe('OpenWhiskCompilePackages', () => {
68
68
} )
69
69
} )
70
70
71
+ describe ( '#calculatePackageName()' , ( ) => {
72
+ it ( 'should return package name from object key' , ( ) => {
73
+ expect ( openwhiskCompilePackages . calculatePackageName ( 'a' , { parameters : 'p' } ) ) . to . equal ( 'a' ) ;
74
+ } )
75
+
76
+ it ( 'should return package name from name property' , ( ) => {
77
+ expect ( openwhiskCompilePackages . calculatePackageName ( 'a' , { name : 'b' } ) ) . to . equal ( 'b' ) ;
78
+ } )
79
+ } )
80
+
71
81
describe ( '#mergeActionPackages()' , ( ) => {
72
82
it ( 'should set up packages from action names' , ( ) => {
73
83
openwhiskCompilePackages . serverless . service . resources = { } ;
@@ -177,5 +187,20 @@ describe('OpenWhiskCompilePackages', () => {
177
187
expect ( log . calledOnce ) . to . be . equal ( true ) ;
178
188
expect ( log . args [ 0 ] [ 0 ] ) . to . be . equal ( `Compiled Package (myPackage): ${ JSON . stringify ( result ) } ` ) ;
179
189
} ) ;
190
+
191
+ it ( 'should rename packages when name parameter is present' , ( ) => {
192
+ const params = { name : 'customname' , shared : true , overwrite : false , namespace : 'another_ns' , parameters : { hello : 'world' } } ;
193
+ const expected = {
194
+ name : 'customname' ,
195
+ overwrite : false ,
196
+ namespace : 'another_ns' ,
197
+ package : {
198
+ publish : true ,
199
+ parameters : [ { key : 'hello' , value : 'world' } ]
200
+ } ,
201
+ } ;
202
+ const result = openwhiskCompilePackages . compilePackage ( 'testing' , params ) ;
203
+ return expect ( result ) . to . deep . equal ( expected ) ;
204
+ } ) ;
180
205
} ) ;
181
206
} ) ;
0 commit comments