diff options
author | Sebastian <sebasjm@gmail.com> | 2022-11-04 11:48:39 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-11-04 11:56:06 -0300 |
commit | 9a9629249e1ec9f2fc5a4147db6d649a3cc17b40 (patch) | |
tree | 8502ea78b0be9ffcf696d9a835388038f3223f5c /packages | |
parent | a69e559890d888d10739c8e29549ff37b788743a (diff) |
fix some test style and SWRConfig type compilation
Diffstat (limited to 'packages')
9 files changed, 34 insertions, 36 deletions
diff --git a/packages/merchant-backoffice-ui/tests/hooks/async.test.ts b/packages/merchant-backoffice-ui/tests/hooks/async.test.ts index a6d0cddfa..ebdfc9bb9 100644 --- a/packages/merchant-backoffice-ui/tests/hooks/async.test.ts +++ b/packages/merchant-backoffice-ui/tests/hooks/async.test.ts @@ -15,7 +15,7 @@ */ import { renderHook } from "@testing-library/preact-hooks" -import { useAsync } from "../../src/hooks/async" +import { useAsync } from "../../src/hooks/async.js" /** * diff --git a/packages/merchant-backoffice-ui/tests/hooks/listener.test.ts b/packages/merchant-backoffice-ui/tests/hooks/listener.test.ts index 3320b044e..597243f76 100644 --- a/packages/merchant-backoffice-ui/tests/hooks/listener.test.ts +++ b/packages/merchant-backoffice-ui/tests/hooks/listener.test.ts @@ -37,8 +37,8 @@ test('listener', async () => { const { result } = renderHook(() => useListener(addWorldToTheEnd)) + expect(result.current).toBeDefined() if (!result.current) { - expect(result.current).toBeDefined() return; } diff --git a/packages/merchant-backoffice-ui/tests/hooks/swr/index.tsx b/packages/merchant-backoffice-ui/tests/hooks/swr/index.tsx index 1cf9220d6..655081711 100644 --- a/packages/merchant-backoffice-ui/tests/hooks/swr/index.tsx +++ b/packages/merchant-backoffice-ui/tests/hooks/swr/index.tsx @@ -28,6 +28,7 @@ interface TestingContextProps { children?: ComponentChildren; } export function TestingContext({ children }: TestingContextProps): VNode { + const SC: any = SWRConfig return ( <BackendContextProvider defaultUrl="http://backend" initialToken="token"> <InstanceContextProvider @@ -38,7 +39,7 @@ export function TestingContext({ children }: TestingContextProps): VNode { changeToken: () => null, }} > - <SWRConfig value={{ provider: () => new Map() }}>{children}</SWRConfig> + <SC value={{ provider: () => new Map() }}>{children}</SC> </InstanceContextProvider> </BackendContextProvider> ); diff --git a/packages/merchant-backoffice-ui/tests/hooks/swr/instance.test.ts b/packages/merchant-backoffice-ui/tests/hooks/swr/instance.test.ts index 5bc463e74..2a1fd76ee 100644 --- a/packages/merchant-backoffice-ui/tests/hooks/swr/instance.test.ts +++ b/packages/merchant-backoffice-ui/tests/hooks/swr/instance.test.ts @@ -37,7 +37,7 @@ import { } from "../../axiosMock.js"; import { TestingContext } from "./index.js"; -describe("instance api interaction with details ", () => { +describe("instance api interaction with details", () => { it("should evict cache when updating an instance", async () => { @@ -59,8 +59,8 @@ describe("instance api interaction with details ", () => { { wrapper: TestingContext } ); + expect(result.current).toBeDefined(); if (!result.current) { - expect(result.current).toBeDefined(); return; } expect(result.current.query.loading).toBeTruthy(); @@ -135,8 +135,8 @@ describe("instance api interaction with details ", () => { { wrapper: TestingContext } ); + expect(result.current).toBeDefined(); if (!result.current) { - expect(result.current).toBeDefined(); return; } expect(result.current.query.loading).toBeTruthy(); @@ -222,8 +222,8 @@ describe("instance api interaction with details ", () => { { wrapper: TestingContext } ); + expect(result.current).toBeDefined(); if (!result.current) { - expect(result.current).toBeDefined(); return; } expect(result.current.query.loading).toBeTruthy(); @@ -284,7 +284,7 @@ describe("instance api interaction with details ", () => { }); }); -describe("instance admin api interaction with listing ", () => { +describe("instance admin api interaction with listing", () => { it("should evict cache when creating a new instance", async () => { const env = new AxiosMockEnvironment(); @@ -307,8 +307,8 @@ describe("instance admin api interaction with listing ", () => { { wrapper: TestingContext } ); + expect(result.current).toBeDefined(); if (!result.current) { - expect(result.current).toBeDefined(); return; } expect(result.current.query.loading).toBeTruthy(); @@ -397,8 +397,8 @@ describe("instance admin api interaction with listing ", () => { { wrapper: TestingContext } ); + expect(result.current).toBeDefined(); if (!result.current) { - expect(result.current).toBeDefined(); return; } expect(result.current.query.loading).toBeTruthy(); @@ -481,8 +481,8 @@ describe("instance admin api interaction with listing ", () => { { wrapper: TestingContext } ); + expect(result.current).toBeDefined(); if (!result.current) { - expect(result.current).toBeDefined(); return; } expect(result.current.query.loading).toBeTruthy(); @@ -545,7 +545,7 @@ describe("instance admin api interaction with listing ", () => { }); }); -describe("instance management api interaction with listing ", () => { +describe("instance management api interaction with listing", () => { it("should evict cache when updating an instance", async () => { const env = new AxiosMockEnvironment(); @@ -569,8 +569,8 @@ describe("instance management api interaction with listing ", () => { { wrapper: TestingContext } ); + expect(result.current).toBeDefined(); if (!result.current) { - expect(result.current).toBeDefined(); return; } expect(result.current.query.loading).toBeTruthy(); diff --git a/packages/merchant-backoffice-ui/tests/hooks/swr/order.test.ts b/packages/merchant-backoffice-ui/tests/hooks/swr/order.test.ts index 29f117df6..31444d942 100644 --- a/packages/merchant-backoffice-ui/tests/hooks/swr/order.test.ts +++ b/packages/merchant-backoffice-ui/tests/hooks/swr/order.test.ts @@ -62,8 +62,8 @@ describe("order api interaction with listing", () => { return { query, api }; }, { wrapper: TestingContext }); + expect(result.current).toBeDefined(); if (!result.current) { - expect(result.current).toBeDefined(); return; } @@ -143,8 +143,8 @@ describe("order api interaction with listing", () => { return { query, api }; }, { wrapper: TestingContext }); + expect(result.current).toBeDefined(); if (!result.current) { - expect(result.current).toBeDefined(); return; } @@ -234,8 +234,8 @@ describe("order api interaction with listing", () => { return { query, api }; }, { wrapper: TestingContext }); + expect(result.current).toBeDefined(); if (!result.current) { - expect(result.current).toBeDefined(); return; } @@ -305,8 +305,8 @@ describe("order api interaction with details", () => { return { query, api }; }, { wrapper: TestingContext }); + expect(result.current).toBeDefined(); if (!result.current) { - expect(result.current).toBeDefined(); return; } @@ -374,8 +374,8 @@ describe("order api interaction with details", () => { return { query, api }; }, { wrapper: TestingContext }); + expect(result.current).toBeDefined(); if (!result.current) { - expect(result.current).toBeDefined(); return; } diff --git a/packages/merchant-backoffice-ui/tests/hooks/swr/product.test.ts b/packages/merchant-backoffice-ui/tests/hooks/swr/product.test.ts index 9beaec747..3ea03e3c7 100644 --- a/packages/merchant-backoffice-ui/tests/hooks/swr/product.test.ts +++ b/packages/merchant-backoffice-ui/tests/hooks/swr/product.test.ts @@ -34,7 +34,7 @@ import { AxiosMockEnvironment } from "../../axiosMock.js"; -describe("product api interaction with listing ", () => { +describe("product api interaction with listing", () => { it("should evict cache when creating a product", async () => { const env = new AxiosMockEnvironment(); @@ -56,8 +56,8 @@ describe("product api interaction with listing ", () => { { wrapper: TestingContext } ); // get products -> loading + expect(result.current).toBeDefined(); if (!result.current) { - expect(result.current).toBeDefined(); return; } expect(result.current.query.loading).toBeTruthy(); @@ -141,8 +141,8 @@ describe("product api interaction with listing ", () => { { wrapper: TestingContext } ); // get products -> loading + expect(result.current).toBeDefined(); if (!result.current) { - expect(result.current).toBeDefined(); return; } expect(result.current.query.loading).toBeTruthy(); @@ -218,8 +218,8 @@ describe("product api interaction with listing ", () => { { wrapper: TestingContext } ); // get products -> loading + expect(result.current).toBeDefined(); if (!result.current) { - expect(result.current).toBeDefined(); return; } expect(result.current.query.loading).toBeTruthy(); @@ -289,8 +289,8 @@ describe("product api interaction with details", () => { return { query, api }; }, { wrapper: TestingContext }); + expect(result.current).toBeDefined(); if (!result.current) { - expect(result.current).toBeDefined(); return; } expect(result.current.query.loading).toBeTruthy(); diff --git a/packages/merchant-backoffice-ui/tests/hooks/swr/reserve.test.ts b/packages/merchant-backoffice-ui/tests/hooks/swr/reserve.test.ts index ba01b380e..deae9d389 100644 --- a/packages/merchant-backoffice-ui/tests/hooks/swr/reserve.test.ts +++ b/packages/merchant-backoffice-ui/tests/hooks/swr/reserve.test.ts @@ -41,7 +41,7 @@ import { } from "../../axiosMock.js"; import { TestingContext } from "./index.js"; -describe("reserve api interaction with listing ", () => { +describe("reserve api interaction with listing", () => { it("should evict cache when creating a reserve", async () => { const env = new AxiosMockEnvironment(); @@ -65,8 +65,8 @@ describe("reserve api interaction with listing ", () => { { wrapper: TestingContext } ); + expect(result.current).toBeDefined(); if (!result.current) { - expect(result.current).toBeDefined(); return; } expect(result.current.query.loading).toBeTruthy(); @@ -171,8 +171,8 @@ describe("reserve api interaction with listing ", () => { } ); + expect(result.current).toBeDefined(); if (!result.current) { - expect(result.current).toBeDefined(); return; } expect(result.current.query.loading).toBeTruthy(); @@ -260,8 +260,8 @@ describe("reserve api interaction with details", () => { } ); + expect(result.current).toBeDefined(); if (!result.current) { - expect(result.current).toBeDefined(); return; } expect(result.current.query.loading).toBeTruthy(); @@ -353,8 +353,8 @@ describe("reserve api interaction with details", () => { } ); + expect(result.current).toBeDefined(); if (!result.current) { - expect(result.current).toBeDefined(); return; } expect(result.current.query.loading).toBeTruthy(); @@ -448,8 +448,8 @@ describe("reserve api interaction with tip details", () => { } ); + expect(result.current).toBeDefined(); if (!result.current) { - expect(result.current).toBeDefined(); return; } expect(result.current.query.loading).toBeTruthy(); diff --git a/packages/merchant-backoffice-ui/tests/hooks/swr/transfer.test.ts b/packages/merchant-backoffice-ui/tests/hooks/swr/transfer.test.ts index 54c908629..45efea04c 100644 --- a/packages/merchant-backoffice-ui/tests/hooks/swr/transfer.test.ts +++ b/packages/merchant-backoffice-ui/tests/hooks/swr/transfer.test.ts @@ -62,8 +62,8 @@ describe("transfer api interaction with listing", () => { return { query, api }; }, { wrapper: TestingContext }); + expect(result.current).toBeDefined(); if (!result.current) { - expect(result.current).toBeDefined(); return; } diff --git a/packages/merchant-backoffice-ui/tests/stories.test.tsx b/packages/merchant-backoffice-ui/tests/stories.test.tsx index b7336efde..b53b703e9 100644 --- a/packages/merchant-backoffice-ui/tests/stories.test.tsx +++ b/packages/merchant-backoffice-ui/tests/stories.test.tsx @@ -42,14 +42,11 @@ function getFiles(dir: string, files_: string[] = []) { const STORIES_NAME_REGEX = RegExp(".*.stories.tsx"); function render(vnode: VNode) { + const SC: any = SWRConfig return originalRender( - <SWRConfig - value={{ - provider: () => new Map(), - }} - > + <SC value={{ provider: () => new Map() }}> {vnode} - </SWRConfig>, + </SC>, ); } |