fix some test style and SWRConfig type compilation
This commit is contained in:
parent
a69e559890
commit
9a9629249e
@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import { renderHook } from "@testing-library/preact-hooks"
|
||||
import { useAsync } from "../../src/hooks/async"
|
||||
import { useAsync } from "../../src/hooks/async.js"
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -37,8 +37,8 @@ test('listener', async () => {
|
||||
|
||||
const { result } = renderHook(() => useListener(addWorldToTheEnd))
|
||||
|
||||
if (!result.current) {
|
||||
expect(result.current).toBeDefined()
|
||||
if (!result.current) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -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>
|
||||
);
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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>,
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user