Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sinamics committed Dec 15, 2024
1 parent 61fd918 commit b71c93f
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/__tests__/__mocks__/networkById.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@ jest.mock("../../utils/api", () => ({
}),
},
},
settings: {
getAllOptions: {
useQuery: () => ({
data: {},
isLoading: false,
refetch: jest.fn(),
}),
},
getPublicOptions: {
useQuery: () => ({
data: {},
isLoading: false,
refetch: jest.fn(),
}),
},
},
networkMember: {
getNetworkMemberById: {
useQuery: () => ({
Expand Down
16 changes: 16 additions & 0 deletions src/__tests__/pages/auth/signin.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ jest.mock("../../../utils/api", () => ({
}),
},
},
settings: {
getAllOptions: {
useQuery: () => ({
data: {},
isLoading: false,
refetch: jest.fn(),
}),
},
getPublicOptions: {
useQuery: () => ({
data: {},
isLoading: false,
refetch: jest.fn(),
}),
},
},
network: {
getUserNetworks: {
useQuery: jest.fn(),
Expand Down
30 changes: 29 additions & 1 deletion src/__tests__/pages/network/[id].test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,34 @@ jest.mock("~/server/db", () => ({
},
}));

jest.mock("../../../utils/api", () => {
return {
api: {
settings: {
getAllOptions: {
useQuery: () => ({
data: {},
isLoading: false,
refetch: jest.fn(),
}),
},
getPublicOptions: {
useQuery: () => ({
data: {},
isLoading: false,
refetch: jest.fn(),
}),
},
},
network: {
getNetworkById: {
useQuery: jest.fn(),
},
},
},
};
});

jest.mock("~/components/auth/withAuth", () => ({
withAuth: jest.fn().mockImplementation((gssp) => gssp),
}));
Expand Down Expand Up @@ -66,6 +94,7 @@ describe("NetworkById component", () => {
refetch: jest.fn(),
});
api.network.getNetworkById.useQuery = useQueryMock;

const context = {
params: { orgIds: [] } as ParsedUrlQuery,
locale: "en",
Expand Down Expand Up @@ -351,7 +380,6 @@ describe("NetworkById component", () => {
});

api.network.getNetworkById.useQuery = useQueryMock;

render(
<QueryClientProvider client={queryClient}>
<NextIntlClientProvider locale="en" messages={enTranslation}>
Expand Down
16 changes: 16 additions & 0 deletions src/__tests__/pages/network/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ jest.mock("../../../utils/api", () => ({
useQuery: jest.fn(),
},
},
settings: {
getAllOptions: {
useQuery: () => ({
data: {},
isLoading: false,
refetch: jest.fn(),
}),
},
getPublicOptions: {
useQuery: () => ({
data: {},
isLoading: false,
refetch: jest.fn(),
}),
},
},
network: {
getUserNetworks: {
useQuery: jest.fn(),
Expand Down

0 comments on commit b71c93f

Please sign in to comment.