@@ -13,6 +13,7 @@ import { describe, expect, it, test, vi } from 'vitest';
1313import { waitAsync } from 'yammies/async' ;
1414
1515import { MobxQuery } from './mobx-query' ;
16+ import { MobxQueryClient } from './mobx-query-client' ;
1617import {
1718 MobxQueryConfig ,
1819 MobxQueryDynamicOptions ,
@@ -39,10 +40,11 @@ class MobxQueryMock<
3940
4041 constructor (
4142 options : Omit < MobxQueryConfig < TData , TError , TQueryKey > , 'queryClient' > ,
43+ queryClient ?: QueryClient ,
4244 ) {
4345 super ( {
4446 ...options ,
45- queryClient : new QueryClient ( { } ) ,
47+ queryClient : queryClient ?? new QueryClient ( { } ) ,
4648 // @ts -ignore
4749 queryFn : vi . fn ( ( ...args : any [ ] ) => {
4850 // @ts -ignore
@@ -195,6 +197,27 @@ describe('MobxQuery', () => {
195197 } ) ;
196198
197199 describe ( '"enabled" reactive parameter' , ( ) => {
200+ it ( 'should work' , async ( ) => {
201+ const queryClient = new MobxQueryClient ( {
202+ defaultOptions : {
203+ queries : {
204+ enabled : false ,
205+ } ,
206+ } ,
207+ } ) ;
208+ const mobxQuery = new MobxQueryMock (
209+ {
210+ queryKey : [ 'test' , 0 as number ] as const ,
211+ queryFn : ( ) => 100 ,
212+ } ,
213+ queryClient ,
214+ ) ;
215+
216+ expect ( mobxQuery . spies . queryFn ) . toBeCalledTimes ( 0 ) ;
217+
218+ mobxQuery . dispose ( ) ;
219+ } ) ;
220+
198221 it ( 'should be reactive after change queryKey' , async ( ) => {
199222 const mobxQuery = new MobxQueryMock ( {
200223 queryKey : [ 'test' , 0 as number ] as const ,
0 commit comments