@@ -102,7 +102,8 @@ afterEach(restoreConsole);
102102
103103describe ( 'functions_slack_search' , ( ) => {
104104 before ( async ( ) => {
105- require ( '../index.js' ) ;
105+ const mod = require ( '../index.js' ) ;
106+ mod . verifyWebhook = ( ) => { } ;
106107 } ) ;
107108 it ( 'Send fails if not a POST request' , async ( ) => {
108109 const error = new Error ( 'Only POST requests are accepted' ) ;
@@ -127,7 +128,8 @@ describe('functions_slack_search', () => {
127128
128129describe ( 'functions_slack_request functions_slack_search functions_verify_webhook' , ( ) => {
129130 it ( 'Handles search error' , async ( ) => {
130- const error = new Error ( 'error' ) ;
131+ const error = new Error ( 'Invalid Slack signature' ) ;
132+ error . code = 401 ;
131133 const mocks = getMocks ( ) ;
132134 const sample = getSample ( ) ;
133135
@@ -147,7 +149,7 @@ describe('functions_slack_request functions_slack_search functions_verify_webhoo
147149 err . message === 'Invalid Slack signature'
148150 ) ;
149151 assert . strictEqual ( mocks . res . status . callCount , 1 ) ;
150- assert . deepStrictEqual ( mocks . res . status . firstCall . args , [ 500 ] ) ;
152+ assert . deepStrictEqual ( mocks . res . status . firstCall . args , [ error . code ] ) ;
151153 assert . strictEqual ( mocks . res . send . callCount , 1 ) ;
152154 assert . deepStrictEqual ( mocks . res . send . firstCall . args , [ error ] ) ;
153155 assert . strictEqual ( console . error . callCount , 1 ) ;
0 commit comments