chore: codify React component style
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
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 type { FC, PropsWithChildren } from "react";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { configureAuthClient } from "@/shared/api";
|
||||
@@ -17,11 +17,15 @@ describe("usePortfolio", () => {
|
||||
clear: vi.fn(),
|
||||
});
|
||||
const client = new QueryClient();
|
||||
const wrapper = ({ children }: { children: ReactNode }) => (
|
||||
<MantineProvider>
|
||||
<QueryClientProvider client={client}>{children}</QueryClientProvider>
|
||||
</MantineProvider>
|
||||
);
|
||||
const wrapper: FC<PropsWithChildren> = (props) => {
|
||||
const { children } = props;
|
||||
|
||||
return (
|
||||
<MantineProvider>
|
||||
<QueryClientProvider client={client}>{children}</QueryClientProvider>
|
||||
</MantineProvider>
|
||||
);
|
||||
};
|
||||
|
||||
const { result } = renderHook(() => usePortfolio("account-1"), {
|
||||
wrapper,
|
||||
|
||||
@@ -6,10 +6,10 @@ const portfolioQueryPolicy = {
|
||||
retry: false,
|
||||
} as const;
|
||||
|
||||
export type Portfolio =
|
||||
type Portfolio =
|
||||
paths["/api/v1/brokerage-accounts/{accountId}/portfolio"]["get"]["responses"][200]["content"]["application/json"];
|
||||
|
||||
export function usePortfolio(accountId: string | undefined) {
|
||||
function usePortfolio(accountId: string | undefined) {
|
||||
return useAuthenticatedQuery({
|
||||
...apiQueryClient.queryOptions(
|
||||
"get",
|
||||
@@ -20,3 +20,5 @@ export function usePortfolio(accountId: string | undefined) {
|
||||
...portfolioQueryPolicy,
|
||||
});
|
||||
}
|
||||
|
||||
export { type Portfolio, usePortfolio };
|
||||
|
||||
Reference in New Issue
Block a user