@@ -165,7 +165,7 @@ describe('Contentstack Debug Logging Integration', () => {
165165 mockClient . restore ( ) ;
166166 } ) ;
167167
168- it ( 'should execute cache adapter when cacheOptions is provided' , async ( ) => {
168+ it ( 'should set cache adapter when cacheOptions is provided' , ( ) => {
169169 const config : StackConfig = {
170170 apiKey : "apiKey" ,
171171 deliveryToken : "delivery" ,
@@ -178,18 +178,49 @@ describe('Contentstack Debug Logging Integration', () => {
178178
179179 const stack = Contentstack . stack ( config ) ;
180180 const client = stack . getClient ( ) ;
181- const mockClient = new MockAdapter ( client ) ;
182181
183- mockClient . onGet ( '/content_types/test' ) . reply ( 200 , {
184- content_types : [ ]
185- } ) ;
182+ // Verify the custom adapter was set
183+ const customAdapter = client . defaults . adapter ;
184+ expect ( customAdapter ) . toBeDefined ( ) ;
185+ expect ( typeof customAdapter ) . toBe ( 'function' ) ;
186+ } ) ;
187+
188+ it ( 'should set cache adapter with NETWORK_ELSE_CACHE policy' , ( ) => {
189+ const config : StackConfig = {
190+ apiKey : "apiKey" ,
191+ deliveryToken : "delivery" ,
192+ environment : "env" ,
193+ cacheOptions : {
194+ policy : Policy . NETWORK_ELSE_CACHE ,
195+ maxAge : 3600 ,
196+ } ,
197+ } ;
198+
199+ const stack = Contentstack . stack ( config ) ;
200+ const client = stack . getClient ( ) ;
186201
187- // Make request to trigger cache adapter
188- await client . get ( '/content_types/test' , { contentTypeUid : 'test' } ) ;
202+ const customAdapter = client . defaults . adapter ;
203+ expect ( customAdapter ) . toBeDefined ( ) ;
204+ expect ( typeof customAdapter ) . toBe ( 'function' ) ;
205+ } ) ;
189206
190- expect ( client . defaults . adapter ) . toBeDefined ( ) ;
207+ it ( 'should set cache adapter with CACHE_ELSE_NETWORK policy' , ( ) => {
208+ const config : StackConfig = {
209+ apiKey : "apiKey" ,
210+ deliveryToken : "delivery" ,
211+ environment : "env" ,
212+ cacheOptions : {
213+ policy : Policy . CACHE_ELSE_NETWORK ,
214+ maxAge : 3600 ,
215+ } ,
216+ } ;
191217
192- mockClient . restore ( ) ;
218+ const stack = Contentstack . stack ( config ) ;
219+ const client = stack . getClient ( ) ;
220+
221+ const customAdapter = client . defaults . adapter ;
222+ expect ( customAdapter ) . toBeDefined ( ) ;
223+ expect ( typeof customAdapter ) . toBe ( 'function' ) ;
193224 } ) ;
194225} ) ;
195226
0 commit comments