refactor: centralize frontend auth query gating
This commit is contained in:
@@ -2,12 +2,20 @@ import { MantineProvider } from "@mantine/core";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import { renderHook, waitFor } from "@testing-library/react";
|
||||
import type { ReactNode } from "react";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { configureAuthClient } from "@/shared/api";
|
||||
import { usePortfolio } from "./usePortfolio";
|
||||
|
||||
describe("usePortfolio", () => {
|
||||
afterEach(() => configureAuthClient(null));
|
||||
|
||||
it("uses the account endpoint with a 30 second cache and no retry", async () => {
|
||||
configureAuthClient({
|
||||
accessToken: () => "token",
|
||||
refresh: async () => true,
|
||||
clear: vi.fn(),
|
||||
});
|
||||
const client = new QueryClient();
|
||||
const wrapper = ({ children }: { children: ReactNode }) => (
|
||||
<MantineProvider>
|
||||
@@ -15,7 +23,7 @@ describe("usePortfolio", () => {
|
||||
</MantineProvider>
|
||||
);
|
||||
|
||||
const { result } = renderHook(() => usePortfolio("account-1", "token"), {
|
||||
const { result } = renderHook(() => usePortfolio("account-1"), {
|
||||
wrapper,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user