@@ -38,15 +38,11 @@ const getSample = () => {
3838 const googleapis = {
3939 kgsearch : sinon . stub ( ) . returns ( kgsearch ) ,
4040 } ;
41- const eventsApi = {
42- verifyRequestSignature : sinon . stub ( ) . returns ( true ) ,
43- } ;
4441
4542 return {
4643 program : proxyquire ( '../' , {
4744 '@googleapis/kgsearch' : googleapis ,
4845 process : { env : config } ,
49- '@slack/events-api' : eventsApi ,
5046 } ) ,
5147 mocks : {
5248 googleapis : googleapis ,
@@ -127,33 +123,6 @@ describe('functions_slack_search', () => {
127123 } ) ;
128124} ) ;
129125
130- describe ( 'functions_slack_search functions_verify_webhook' , ( ) => {
131- it ( 'Throws if invalid slack token' , async ( ) => {
132- const error = new Error ( 'Invalid credentials' ) ;
133- error . code = 401 ;
134- const mocks = getMocks ( ) ;
135- const sample = getSample ( ) ;
136-
137- mocks . req . method = method ;
138- mocks . req . body . text = 'not empty' ;
139- sample . mocks . eventsApi . verifyRequestSignature = sinon . stub ( ) . returns ( false ) ;
140-
141- const kgSearch = getFunction ( 'kgSearch' ) ;
142-
143- try {
144- await kgSearch ( mocks . req , mocks . res ) ;
145- } catch ( err ) {
146- assert . deepStrictEqual ( err , error ) ;
147- assert . strictEqual ( mocks . res . status . callCount , 1 ) ;
148- assert . deepStrictEqual ( mocks . res . status . firstCall . args , [ error . code ] ) ;
149- assert . strictEqual ( mocks . res . send . callCount , 1 ) ;
150- assert . deepStrictEqual ( mocks . res . send . firstCall . args , [ error ] ) ;
151- assert . strictEqual ( console . error . callCount , 1 ) ;
152- assert . deepStrictEqual ( console . error . firstCall . args , [ error ] ) ;
153- }
154- } ) ;
155- } ) ;
156-
157126describe ( 'functions_slack_request functions_slack_search functions_verify_webhook' , ( ) => {
158127 it ( 'Handles search error' , async ( ) => {
159128 const error = new Error ( 'error' ) ;
0 commit comments