Skip to content

Commit

Permalink
chore: upgrade version
Browse files Browse the repository at this point in the history
  - migrate react-testing-library to support react 18 ([unsolved warning](testing-library/react-testing-library#1051))
  - vitest to 0.10.0
  • Loading branch information
lifeisegg123 committed May 1, 2022
1 parent 1b6091e commit 4968241
Show file tree
Hide file tree
Showing 6 changed files with 193 additions and 124 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"lint": "eslint ."
},
"devDependencies": {
"@testing-library/react-hooks": "^8.0.0",
"@testing-library/react": "^13.1.1",
"@typescript-eslint/eslint-plugin": "^5.19.0",
"@typescript-eslint/parser": "^5.19.0",
"@vitejs/plugin-react": "^1.3.1",
Expand All @@ -51,7 +51,7 @@
"react-query": "^4.0.0-beta.3",
"typescript": "^4.5.4",
"vite": "^2.9.2",
"vitest": "^0.9.3"
"vitest": "^0.10.0"
},
"peerDependencies": {
"react-query": "^4"
Expand Down
114 changes: 86 additions & 28 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 12 additions & 9 deletions test/createMutationToolkit.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { vi, expect, it, describe } from "vitest";
import { act, waitFor } from "@testing-library/react";

import { createMutationToolkit } from "../src/createMutationToolkit";
import { customRenderHook, mockQueryClient } from "./utils";
Expand All @@ -20,17 +21,19 @@ describe("createMutationToolkit", () => {
});

it("should handle useMutation", async () => {
const { result, waitFor } = customRenderHook(() =>
mockApiMutation.useMutation(),
);
const res = await result.current.mutateAsync(1);
expect(res).toBe(null);
expect(count).toBe(1);
const { result } = customRenderHook(() => mockApiMutation.useMutation());
await act(async () => {
const res = await result.current.mutateAsync(1);
expect(res).toBe(null);
expect(count).toBe(1);
});

result.current.mutate(2);
await waitFor(() => result.current.isSuccess);
expect(count).toEqual(3);
expect(mockOnSuccess).toBeCalledTimes(2);

await waitFor(() => {
expect(mockOnSuccess).toBeCalledTimes(2);
expect(count).toEqual(3);
});
});

it("should indicate proper isMutating", async () => {
Expand Down
Loading

0 comments on commit 4968241

Please sign in to comment.