@@ -68,6 +68,16 @@ describe('OpenWhiskCompilePackages', () => {
6868 } )
6969 } )
7070
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+
7181 describe ( '#mergeActionPackages()' , ( ) => {
7282 it ( 'should set up packages from action names' , ( ) => {
7383 openwhiskCompilePackages . serverless . service . resources = { } ;
@@ -177,5 +187,20 @@ describe('OpenWhiskCompilePackages', () => {
177187 expect ( log . calledOnce ) . to . be . equal ( true ) ;
178188 expect ( log . args [ 0 ] [ 0 ] ) . to . be . equal ( `Compiled Package (myPackage): ${ JSON . stringify ( result ) } ` ) ;
179189 } ) ;
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+ } ) ;
180205 } ) ;
181206} ) ;
0 commit comments