@@ -6,6 +6,8 @@ import { getMissingParamError, setUpConnection, initSDK, getConnectSbError } fro
66import { SetupConnectionTypes } from '../types' ;
77import { generateSetUpConnectionParams , mockSdk , mockUser , mockUser2 } from './data.mocks' ;
88import { SendbirdError } from '@sendbird/chat' ;
9+ import { OpenChannelModule } from '@sendbird/chat/openChannel' ;
10+ import { GroupChannelModule } from '@sendbird/chat/groupChannel' ;
911
1012// todo: combine after mock-sdk is implemented
1113jest . mock ( '@sendbird/chat' , ( ) => {
@@ -196,10 +198,8 @@ describe('useConnect/setupConnection/initSDK', () => {
196198 newInstance : false ,
197199 localCacheEnabled : true ,
198200 modules : [
199- // @ts -ignore
200- new ( require ( '@sendbird/chat/groupChannel' ) . GroupChannelModule ) ( ) ,
201- // @ts -ignore
202- new ( require ( '@sendbird/chat/openChannel' ) . OpenChannelModule ) ( ) ,
201+ GroupChannelModule ,
202+ OpenChannelModule ,
203203 ] ,
204204 } ) ;
205205 expect ( newSdk ) . toEqual ( mockSdk ) ;
@@ -215,10 +215,8 @@ describe('useConnect/setupConnection/initSDK', () => {
215215 newInstance : false ,
216216 localCacheEnabled : true ,
217217 modules : [
218- // @ts -ignore
219- new ( require ( '@sendbird/chat/groupChannel' ) . GroupChannelModule ) ( ) ,
220- // @ts -ignore
221- new ( require ( '@sendbird/chat/openChannel' ) . OpenChannelModule ) ( ) ,
218+ GroupChannelModule ,
219+ OpenChannelModule ,
222220 ] ,
223221 customApiHost,
224222 customWebSocketHost,
@@ -236,10 +234,8 @@ describe('useConnect/setupConnection/initSDK', () => {
236234 newInstance : false ,
237235 localCacheEnabled : true ,
238236 modules : [
239- // @ts -ignore
240- new ( require ( '@sendbird/chat/groupChannel' ) . GroupChannelModule ) ( ) ,
241- // @ts -ignore
242- new ( require ( '@sendbird/chat/openChannel' ) . OpenChannelModule ) ( ) ,
237+ GroupChannelModule ,
238+ OpenChannelModule ,
243239 ] ,
244240 sdkInitParams,
245241 } ) ;
@@ -256,13 +252,32 @@ describe('useConnect/setupConnection/initSDK', () => {
256252 newInstance : false ,
257253 localCacheEnabled : true ,
258254 modules : [
259- // @ts -ignore
260- new ( require ( '@sendbird/chat/groupChannel' ) . GroupChannelModule ) ( ) ,
261- // @ts -ignore
262- new ( require ( '@sendbird/chat/openChannel' ) . OpenChannelModule ) ( ) ,
255+ GroupChannelModule ,
256+ OpenChannelModule ,
263257 ] ,
264258 customExtensionParams,
265259 } ) ;
266260 expect ( newSdk ) . toEqual ( mockSdk ) ;
267261 } ) ;
262+ it ( 'should override default localCacheEnabled when provided in sdkInitParams' , async ( ) => {
263+ const setUpConnectionProps = generateSetUpConnectionParams ( ) ;
264+ const { appId } = setUpConnectionProps ;
265+ const sdkInitParams = {
266+ localCacheEnabled : false ,
267+ } ;
268+
269+ const newSdk = initSDK ( { appId, sdkInitParams } ) ;
270+
271+ // @ts -ignore
272+ expect ( require ( '@sendbird/chat' ) . init ) . toBeCalledWith ( {
273+ appId,
274+ newInstance : false ,
275+ modules : [
276+ GroupChannelModule ,
277+ OpenChannelModule ,
278+ ] ,
279+ localCacheEnabled : false ,
280+ } ) ;
281+ expect ( newSdk ) . toEqual ( mockSdk ) ;
282+ } ) ;
268283} ) ;
0 commit comments