chore: codify React component style
This commit is contained in:
@@ -2,7 +2,7 @@ import { MantineProvider } from "@mantine/core";
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import { renderHook, waitFor } from "@testing-library/react";
|
||||
import { HttpResponse, http } from "msw";
|
||||
import type { ReactNode } from "react";
|
||||
import type { FC, PropsWithChildren } from "react";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { configureAuthClient } from "@/shared/api";
|
||||
import { server } from "@/test/server";
|
||||
@@ -10,11 +10,17 @@ import { useBrokerageAccounts } from "./useBrokerageAccounts";
|
||||
|
||||
function createWrapper() {
|
||||
const client = new QueryClient();
|
||||
return ({ children }: { children: ReactNode }) => (
|
||||
<MantineProvider>
|
||||
<QueryClientProvider client={client}>{children}</QueryClientProvider>
|
||||
</MantineProvider>
|
||||
);
|
||||
const TestWrapper: FC<PropsWithChildren> = (props) => {
|
||||
const { children } = props;
|
||||
|
||||
return (
|
||||
<MantineProvider>
|
||||
<QueryClientProvider client={client}>{children}</QueryClientProvider>
|
||||
</MantineProvider>
|
||||
);
|
||||
};
|
||||
|
||||
return TestWrapper;
|
||||
}
|
||||
|
||||
describe("useBrokerageAccounts", () => {
|
||||
|
||||
@@ -4,16 +4,21 @@ import type { paths } from "@/shared/api/generated/schema";
|
||||
const brokerageAccountsQueryOptions = () =>
|
||||
apiQueryClient.queryOptions("get", "/api/v1/brokerage-accounts");
|
||||
|
||||
export const brokerageAccountsQueryKey =
|
||||
brokerageAccountsQueryOptions().queryKey;
|
||||
const brokerageAccountsQueryKey = brokerageAccountsQueryOptions().queryKey;
|
||||
|
||||
export type BrokerageAccount =
|
||||
type BrokerageAccount =
|
||||
paths["/api/v1/brokerage-accounts"]["get"]["responses"][200]["content"]["application/json"][number];
|
||||
|
||||
export function useBrokerageAccounts() {
|
||||
function useBrokerageAccounts() {
|
||||
return useAuthenticatedQuery({
|
||||
...brokerageAccountsQueryOptions(),
|
||||
staleTime: 60_000,
|
||||
retry: false,
|
||||
});
|
||||
}
|
||||
|
||||
export {
|
||||
type BrokerageAccount,
|
||||
brokerageAccountsQueryKey,
|
||||
useBrokerageAccounts,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user