Skip to content

Commit 3c1665c

Browse files
committed
test: add unit tests for #10 issues
1 parent a5ce220 commit 3c1665c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/mobx-query.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
MobxQueryInvalidateParams,
2020
MobxQueryUpdateOptions,
2121
} from './mobx-query.types';
22+
import { createQuery } from './preset';
2223

2324
class MobxQueryMock<
2425
TData,
@@ -1101,5 +1102,26 @@ describe('MobxQuery', () => {
11011102
status: 'pending',
11021103
});
11031104
});
1105+
1106+
it('options is not reactive when updating after creating #10', () => {
1107+
const enabled = observable.box(false);
1108+
1109+
const queryFnSpy = vi.fn();
1110+
const getDynamicOptionsSpy = vi.fn();
1111+
1112+
createQuery(queryFnSpy, {
1113+
options: () => {
1114+
getDynamicOptionsSpy();
1115+
return {
1116+
enabled: enabled.get(),
1117+
};
1118+
},
1119+
});
1120+
1121+
enabled.set(true);
1122+
1123+
expect(queryFnSpy).toBeCalledTimes(1);
1124+
expect(getDynamicOptionsSpy).toBeCalledTimes(3);
1125+
});
11041126
});
11051127
});

0 commit comments

Comments
 (0)