Skip to content

Commit aad9bc1

Browse files
committed
fix: unit tests for setData method
1 parent fa72b26 commit aad9bc1

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/mobx-query.test.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
runInAction,
1919
when,
2020
} from 'mobx';
21-
import { afterEach, beforeEach, describe, expect, it, test, vi } from 'vitest';
21+
import { afterEach, describe, expect, it, test, vi } from 'vitest';
2222
import { waitAsync } from 'yummies/async';
2323

2424
import { MobxQuery } from './mobx-query';
@@ -753,15 +753,10 @@ describe('MobxQuery', () => {
753753
});
754754
});
755755

756-
describe.skip('"setData" method', () => {
756+
describe('"setData" method', () => {
757757
const queryClient = new QueryClient();
758758

759-
beforeEach(() => {
760-
// vi.useFakeTimers();
761-
});
762-
763759
afterEach(() => {
764-
// vi.useRealTimers();
765760
vi.restoreAllMocks();
766761
queryClient.clear();
767762
});
@@ -836,6 +831,7 @@ describe('MobxQuery', () => {
836831
);
837832

838833
await when(() => !mobxQuery.result.isLoading);
834+
await waitAsync(10);
839835

840836
mobxQuery.setData((curr) => {
841837
if (!curr) return curr;
@@ -844,7 +840,6 @@ describe('MobxQuery', () => {
844840
});
845841

846842
await when(() => !mobxQuery.result.isLoading);
847-
// await when(() => !mobxQuery.result.isStale);
848843

849844
expect(mobxQuery.spies.queryFn).toBeCalledTimes(1);
850845
expect(mobxQuery.result.data).toEqual({
@@ -911,6 +906,7 @@ describe('MobxQuery', () => {
911906
);
912907

913908
await when(() => !mobxQuery.result.isLoading);
909+
await waitAsync(10);
914910

915911
mobxQuery.setData((curr) => {
916912
if (!curr) return curr;
@@ -1017,6 +1013,7 @@ describe('MobxQuery', () => {
10171013
const testClass = new TestClass();
10181014

10191015
await when(() => !testClass.mobxQuery.result.isLoading);
1016+
await waitAsync(10);
10201017

10211018
expect(testClass.foo).toStrictEqual({
10221019
age: 20,
@@ -1094,6 +1091,7 @@ describe('MobxQuery', () => {
10941091
);
10951092

10961093
await when(() => !testClass.mobxQuery.result.isLoading);
1094+
await waitAsync(10);
10971095

10981096
testClass.mobxQuery.setData((curr) => {
10991097
if (!curr) return curr;

0 commit comments

Comments
 (0)