@@ -138,10 +138,14 @@ describe("slack web client config", () => {
138138 try {
139139 createSlackReadClient ( "xoxb-read" ) ;
140140
141- expect ( WebClient ) . toHaveBeenCalledWith ( "xoxb-read" , {
142- retryConfig : SLACK_DEFAULT_RETRY_OPTIONS ,
143- timeout : 30_000 ,
144- } ) ;
141+ expect ( WebClient ) . toHaveBeenCalledWith (
142+ "xoxb-read" ,
143+ expect . objectContaining ( {
144+ fetch : expect . any ( Function ) ,
145+ retryConfig : SLACK_DEFAULT_RETRY_OPTIONS ,
146+ timeout : 30_000 ,
147+ } ) ,
148+ ) ;
145149 } finally {
146150 restoreProxyEnvForTest ( ) ;
147151 }
@@ -152,10 +156,14 @@ describe("slack web client config", () => {
152156 try {
153157 createSlackReadClient ( "xoxb-read" , { timeout : 60_000 } ) ;
154158
155- expect ( WebClient ) . toHaveBeenCalledWith ( "xoxb-read" , {
156- retryConfig : SLACK_DEFAULT_RETRY_OPTIONS ,
157- timeout : 60_000 ,
158- } ) ;
159+ expect ( WebClient ) . toHaveBeenCalledWith (
160+ "xoxb-read" ,
161+ expect . objectContaining ( {
162+ fetch : expect . any ( Function ) ,
163+ retryConfig : SLACK_DEFAULT_RETRY_OPTIONS ,
164+ timeout : 60_000 ,
165+ } ) ,
166+ ) ;
159167 } finally {
160168 restoreProxyEnvForTest ( ) ;
161169 }
@@ -231,24 +239,33 @@ describe("slack web client config", () => {
231239 slackApiUrl : "https://slack.test/api/" ,
232240 } ) ;
233241
234- expect ( WebClient ) . toHaveBeenCalledWith ( "xoxb-startup" , {
235- fetch : customFetch ,
236- rejectRateLimitedCalls : true ,
237- retryConfig : { retries : 2 , minTimeout : 0 } ,
238- slackApiUrl : "https://slack.test/api/" ,
239- timeout : 10_000 ,
240- } ) ;
242+ expect ( WebClient ) . toHaveBeenCalledWith (
243+ "xoxb-startup" ,
244+ expect . objectContaining ( {
245+ fetch : expect . any ( Function ) ,
246+ retryConfig : { ...SLACK_DEFAULT_RETRY_OPTIONS , maxRetryTime : 35_000 } ,
247+ slackApiUrl : "https://slack.test/api/" ,
248+ timeout : 10_000 ,
249+ } ) ,
250+ ) ;
251+ const options = WebClient . mock . calls [ 0 ] ?. [ 1 ] as Record < string , unknown > ;
252+ expect ( options . fetch ) . not . toBe ( customFetch ) ;
253+ expect ( options ) . not . toHaveProperty ( "rejectRateLimitedCalls" ) ;
241254 } ) ;
242255
243256 it ( "applies the default retry config when constructing a client without proxy env" , ( ) => {
244257 clearProxyEnvForTest ( ) ;
245258 try {
246259 createSlackWebClient ( "xoxb-test" , { timeout : 1234 } ) ;
247260
248- expect ( WebClient ) . toHaveBeenCalledWith ( "xoxb-test" , {
249- retryConfig : SLACK_DEFAULT_RETRY_OPTIONS ,
250- timeout : 1234 ,
251- } ) ;
261+ expect ( WebClient ) . toHaveBeenCalledWith (
262+ "xoxb-test" ,
263+ expect . objectContaining ( {
264+ fetch : expect . any ( Function ) ,
265+ retryConfig : SLACK_DEFAULT_RETRY_OPTIONS ,
266+ timeout : 1234 ,
267+ } ) ,
268+ ) ;
252269 } finally {
253270 restoreProxyEnvForTest ( ) ;
254271 }
@@ -408,9 +425,9 @@ describe("slack proxy dispatcher", () => {
408425 await dispatcher ?. close ( ) ;
409426 } ) ;
410427
411- it ( "does not attach a fetch when no proxy env var is configured" , ( ) => {
428+ it ( "attaches the shared fetch when no proxy env var is configured" , ( ) => {
412429 expect ( resolveSlackProxyDispatcher ( ) ) . toBeUndefined ( ) ;
413- expect ( resolveSlackWebClientOptions ( ) . fetch ) . toBeUndefined ( ) ;
430+ expect ( requireFetch ( resolveSlackWebClientOptions ( ) ) ) . toBeTypeOf ( "function" ) ;
414431 } ) ;
415432
416433 it ( "preserves an explicitly provided fetch" , async ( ) => {
@@ -459,6 +476,6 @@ describe("slack proxy dispatcher", () => {
459476 process . env . HTTPS_PROXY = "not-a-valid-url://:::bad" ;
460477
461478 expect ( resolveSlackProxyDispatcher ( ) ) . toBeUndefined ( ) ;
462- expect ( resolveSlackWebClientOptions ( ) . fetch ) . toBeUndefined ( ) ;
479+ expect ( requireFetch ( resolveSlackWebClientOptions ( ) ) ) . toBeTypeOf ( "function" ) ;
463480 } ) ;
464481} ) ;
0 commit comments