File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
packages/cubejs-client-core/test Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -217,6 +217,30 @@ describe('CubeApi with Abort Signal', () => {
217217 expect ( requestSpy . mock . calls [ 0 ] ?. [ 1 ] ?. signal ) . toBe ( signal ) ;
218218 } ) ;
219219
220+ test ( 'should pass cache from options to request' , async ( ) => {
221+ // Mock for this specific test
222+ const requestSpy = jest . spyOn ( HttpTransport . prototype , 'request' ) . mockImplementation ( ( ) => ( {
223+ subscribe : ( cb ) => Promise . resolve ( cb ( {
224+ status : 200 ,
225+ text : ( ) => Promise . resolve ( '{"results":[]}' ) ,
226+ json : ( ) => Promise . resolve ( { results : [ ] } )
227+ } as any ,
228+ async ( ) => undefined as any ) )
229+ } ) ) ;
230+
231+ const cubeApi = new CubeApi ( 'token' , {
232+ apiUrl : 'http://localhost:4000/cubejs-api/v1'
233+ } ) ;
234+
235+ await cubeApi . load (
236+ { measures : [ 'Orders.count' ] } ,
237+ { cache : "stale-if-slow" }
238+ ) ;
239+
240+ expect ( requestSpy ) . toHaveBeenCalled ( ) ;
241+ expect ( requestSpy . mock . calls [ 0 ] ?. [ 1 ] ?. cache ) . toBe ( "stale-if-slow" ) ;
242+ } ) ;
243+
220244 test ( 'options signal should override constructor signal' , async ( ) => {
221245 const constructorController = new AbortController ( ) ;
222246 const optionsController = new AbortController ( ) ;
You can’t perform that action at this time.
0 commit comments