@@ -27,23 +27,28 @@ describe('Validate', () => {
27
27
describe ( '#validate()' , ( ) => {
28
28
let validateServicePathStub ;
29
29
let validateServiceNameStub ;
30
+ let validateHandlersStub ;
30
31
31
32
beforeEach ( ( ) => {
32
33
validateServicePathStub = sinon . stub ( googleCommand , 'validateServicePath' )
33
34
. returns ( BbPromise . resolve ( ) ) ;
34
35
validateServiceNameStub = sinon . stub ( googleCommand , 'validateServiceName' )
35
36
. returns ( BbPromise . resolve ( ) ) ;
37
+ validateHandlersStub = sinon . stub ( googleCommand , 'validateHandlers' )
38
+ . returns ( BbPromise . resolve ( ) ) ;
36
39
} ) ;
37
40
38
41
afterEach ( ( ) => {
39
42
googleCommand . validateServicePath . restore ( ) ;
40
43
googleCommand . validateServiceName . restore ( ) ;
44
+ googleCommand . validateHandlers . restore ( ) ;
41
45
} ) ;
42
46
43
47
it ( 'should run promise chain' , ( ) => googleCommand
44
48
. validate ( ) . then ( ( ) => {
45
49
expect ( validateServicePathStub . calledOnce ) . toEqual ( true ) ;
46
50
expect ( validateServiceNameStub . calledAfter ( validateServicePathStub ) ) ;
51
+ expect ( validateHandlersStub . calledAfter ( validateServiceNameStub ) ) ;
47
52
} ) ) ;
48
53
} ) ;
49
54
@@ -80,4 +85,29 @@ describe('Validate', () => {
80
85
expect ( ( ) => googleCommand . validateServiceName ( ) ) . not . toThrow ( Error ) ;
81
86
} ) ;
82
87
} ) ;
88
+
89
+ describe ( '#validateHandlers()' , ( ) => {
90
+ it ( 'should throw an error if the handler name contains an invalid character' , ( ) => {
91
+ googleCommand . serverless . service . functions = {
92
+ foo : {
93
+ handler : 'invalid.handler' ,
94
+ } ,
95
+ bar : {
96
+ handler : 'invalid/handler' ,
97
+ } ,
98
+ } ;
99
+
100
+ expect ( ( ) => googleCommand . validateHandlers ( ) ) . toThrow ( Error ) ;
101
+ } ) ;
102
+
103
+ it ( 'should not throw an error if the function handler is valid' , ( ) => {
104
+ googleCommand . serverless . service . functions = {
105
+ foo : {
106
+ handler : 'validHandler' ,
107
+ } ,
108
+ } ;
109
+
110
+ expect ( ( ) => googleCommand . validateHandlers ( ) ) . not . toThrow ( Error ) ;
111
+ } ) ;
112
+ } ) ;
83
113
} ) ;
0 commit comments