Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
/* istanbul ignore file */

export {
QueryClient,
QueryObserver,
QueriesObserver,
InfiniteQueryObserver,
MutationObserver,
QueryCache,
MutationCache,
hydrate,
dehydrate,
focusManager,
Expand Down
44 changes: 44 additions & 0 deletions src/vue/__tests__/mutationCache.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { ref } from "vue-demi";
import { MutationCache as MutationCacheOrigin } from "react-query/core";

import { MutationCache } from "../mutationCache";

describe("MutationCache", () => {
beforeAll(() => {
jest.spyOn(MutationCacheOrigin.prototype, "find");
jest.spyOn(MutationCacheOrigin.prototype, "findAll");
});

beforeEach(() => {
jest.clearAllMocks();
});

describe("find", () => {
test("should properly unwrap parameters", async () => {
const mutationCache = new MutationCache();

mutationCache.find({
mutationKey: ref("baz"),
});

expect(MutationCacheOrigin.prototype.find).toBeCalledWith({
exact: true,
mutationKey: "baz",
});
});
});

describe("findAll", () => {
test("should properly unwrap parameters", async () => {
const mutationCache = new MutationCache();

mutationCache.findAll({
mutationKey: ref("baz"),
});

expect(MutationCacheOrigin.prototype.findAll).toBeCalledWith({
mutationKey: "baz",
});
});
});
});
58 changes: 58 additions & 0 deletions src/vue/__tests__/queryCache.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { ref } from "vue-demi";
import { QueryCache as QueryCacheOrigin } from "react-query/core";

import { QueryCache } from "../queryCache";

describe("QueryCache", () => {
beforeAll(() => {
jest.spyOn(QueryCacheOrigin.prototype, "find");
jest.spyOn(QueryCacheOrigin.prototype, "findAll");
});

beforeEach(() => {
jest.clearAllMocks();
});

describe("find", () => {
test("should properly unwrap parameters", async () => {
const queryCache = new QueryCache();

queryCache.find(["foo", ref("bar")], {
queryKey: ref("baz"),
});

expect(QueryCacheOrigin.prototype.find).toBeCalledWith(["foo", "bar"], {
queryKey: "baz",
});
});
});

describe("findAll", () => {
test("should properly unwrap two parameters", async () => {
const queryCache = new QueryCache();

queryCache.findAll(["foo", ref("bar")], {
queryKey: ref("baz"),
});

expect(QueryCacheOrigin.prototype.findAll).toBeCalledWith(
["foo", "bar"],
{
queryKey: "baz",
}
);
});

test("should properly unwrap one parameter", async () => {
const queryCache = new QueryCache();

queryCache.findAll({
queryKey: ref("baz"),
});

expect(QueryCacheOrigin.prototype.findAll).toBeCalledWith({
queryKey: "baz",
});
});
});
});
Loading