fix some test style and SWRConfig type compilation

This commit is contained in:
Sebastian 2022-11-04 11:48:39 -03:00
parent a69e559890
commit 9a9629249e
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1
9 changed files with 34 additions and 36 deletions

View File

@ -15,7 +15,7 @@
*/
import { renderHook } from "@testing-library/preact-hooks"
import { useAsync } from "../../src/hooks/async"
import { useAsync } from "../../src/hooks/async.js"
/**
*

View File

@ -37,8 +37,8 @@ test('listener', async () => {
const { result } = renderHook(() => useListener(addWorldToTheEnd))
if (!result.current) {
expect(result.current).toBeDefined()
if (!result.current) {
return;
}

View File

@ -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>
);

View File

@ -59,8 +59,8 @@ describe("instance api interaction with details ", () => {
{ wrapper: TestingContext }
);
if (!result.current) {
expect(result.current).toBeDefined();
if (!result.current) {
return;
}
expect(result.current.query.loading).toBeTruthy();
@ -135,8 +135,8 @@ describe("instance api interaction with details ", () => {
{ wrapper: TestingContext }
);
if (!result.current) {
expect(result.current).toBeDefined();
if (!result.current) {
return;
}
expect(result.current.query.loading).toBeTruthy();
@ -222,8 +222,8 @@ describe("instance api interaction with details ", () => {
{ wrapper: TestingContext }
);
if (!result.current) {
expect(result.current).toBeDefined();
if (!result.current) {
return;
}
expect(result.current.query.loading).toBeTruthy();
@ -307,8 +307,8 @@ describe("instance admin api interaction with listing ", () => {
{ wrapper: TestingContext }
);
if (!result.current) {
expect(result.current).toBeDefined();
if (!result.current) {
return;
}
expect(result.current.query.loading).toBeTruthy();
@ -397,8 +397,8 @@ describe("instance admin api interaction with listing ", () => {
{ wrapper: TestingContext }
);
if (!result.current) {
expect(result.current).toBeDefined();
if (!result.current) {
return;
}
expect(result.current.query.loading).toBeTruthy();
@ -481,8 +481,8 @@ describe("instance admin api interaction with listing ", () => {
{ wrapper: TestingContext }
);
if (!result.current) {
expect(result.current).toBeDefined();
if (!result.current) {
return;
}
expect(result.current.query.loading).toBeTruthy();
@ -569,8 +569,8 @@ describe("instance management api interaction with listing ", () => {
{ wrapper: TestingContext }
);
if (!result.current) {
expect(result.current).toBeDefined();
if (!result.current) {
return;
}
expect(result.current.query.loading).toBeTruthy();

View File

@ -62,8 +62,8 @@ describe("order api interaction with listing", () => {
return { query, api };
}, { wrapper: TestingContext });
if (!result.current) {
expect(result.current).toBeDefined();
if (!result.current) {
return;
}
@ -143,8 +143,8 @@ describe("order api interaction with listing", () => {
return { query, api };
}, { wrapper: TestingContext });
if (!result.current) {
expect(result.current).toBeDefined();
if (!result.current) {
return;
}
@ -234,8 +234,8 @@ describe("order api interaction with listing", () => {
return { query, api };
}, { wrapper: TestingContext });
if (!result.current) {
expect(result.current).toBeDefined();
if (!result.current) {
return;
}
@ -305,8 +305,8 @@ describe("order api interaction with details", () => {
return { query, api };
}, { wrapper: TestingContext });
if (!result.current) {
expect(result.current).toBeDefined();
if (!result.current) {
return;
}
@ -374,8 +374,8 @@ describe("order api interaction with details", () => {
return { query, api };
}, { wrapper: TestingContext });
if (!result.current) {
expect(result.current).toBeDefined();
if (!result.current) {
return;
}

View File

@ -56,8 +56,8 @@ describe("product api interaction with listing ", () => {
{ wrapper: TestingContext }
); // get products -> loading
if (!result.current) {
expect(result.current).toBeDefined();
if (!result.current) {
return;
}
expect(result.current.query.loading).toBeTruthy();
@ -141,8 +141,8 @@ describe("product api interaction with listing ", () => {
{ wrapper: TestingContext }
); // get products -> loading
if (!result.current) {
expect(result.current).toBeDefined();
if (!result.current) {
return;
}
expect(result.current.query.loading).toBeTruthy();
@ -218,8 +218,8 @@ describe("product api interaction with listing ", () => {
{ wrapper: TestingContext }
); // get products -> loading
if (!result.current) {
expect(result.current).toBeDefined();
if (!result.current) {
return;
}
expect(result.current.query.loading).toBeTruthy();
@ -289,8 +289,8 @@ describe("product api interaction with details", () => {
return { query, api };
}, { wrapper: TestingContext });
if (!result.current) {
expect(result.current).toBeDefined();
if (!result.current) {
return;
}
expect(result.current.query.loading).toBeTruthy();

View File

@ -65,8 +65,8 @@ describe("reserve api interaction with listing ", () => {
{ wrapper: TestingContext }
);
if (!result.current) {
expect(result.current).toBeDefined();
if (!result.current) {
return;
}
expect(result.current.query.loading).toBeTruthy();
@ -171,8 +171,8 @@ describe("reserve api interaction with listing ", () => {
}
);
if (!result.current) {
expect(result.current).toBeDefined();
if (!result.current) {
return;
}
expect(result.current.query.loading).toBeTruthy();
@ -260,8 +260,8 @@ describe("reserve api interaction with details", () => {
}
);
if (!result.current) {
expect(result.current).toBeDefined();
if (!result.current) {
return;
}
expect(result.current.query.loading).toBeTruthy();
@ -353,8 +353,8 @@ describe("reserve api interaction with details", () => {
}
);
if (!result.current) {
expect(result.current).toBeDefined();
if (!result.current) {
return;
}
expect(result.current.query.loading).toBeTruthy();
@ -448,8 +448,8 @@ describe("reserve api interaction with tip details", () => {
}
);
if (!result.current) {
expect(result.current).toBeDefined();
if (!result.current) {
return;
}
expect(result.current.query.loading).toBeTruthy();

View File

@ -62,8 +62,8 @@ describe("transfer api interaction with listing", () => {
return { query, api };
}, { wrapper: TestingContext });
if (!result.current) {
expect(result.current).toBeDefined();
if (!result.current) {
return;
}

View File

@ -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>,
);
}