Fix frontend tests and story shots after code splitting was enabled

This commit is contained in:
Eduard Heimbuch
2022-03-01 15:33:48 +01:00
parent f125f75dc6
commit 151c7bf772
6 changed files with 220 additions and 4071 deletions

View File

@@ -23,18 +23,24 @@
*/
import { LegacyContext, LegacyContextProvider, useLegacyContext } from "./LegacyContext";
import { FC } from "react";
import * as React from "react";
import { FC } from "react";
import { renderHook } from "@testing-library/react-hooks";
import { QueryClient, QueryClientProvider } from "react-query";
describe("LegacyContext tests", () => {
const queryClient = new QueryClient();
const createWrapper = (context?: LegacyContext): FC => {
return ({ children }) => <LegacyContextProvider {...context}>{children}</LegacyContextProvider>;
return ({ children }) => (
<QueryClientProvider client={queryClient}>
<LegacyContextProvider {...context}>{children}</LegacyContextProvider>
</QueryClientProvider>
);
};
it("should return provided context", () => {
const { result } = renderHook(() => useLegacyContext(), {
wrapper: createWrapper(),
wrapper: createWrapper()
});
expect(result.current).toBeDefined();
});

View File

@@ -33,6 +33,7 @@ export type BaseContext = {
export type LegacyContext = BaseContext & {
initialize: () => void;
queryClient?: QueryClient;
};
const Context = createContext<LegacyContext | undefined>(undefined);

View File

@@ -1,3 +1,4 @@
{
"presets": ["@scm-manager/babel-preset"]
"presets": ["@scm-manager/babel-preset"],
"plugins": ["@babel/plugin-syntax-dynamic-import"]
}

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@
"private": true,
"main": "src/index.ts",
"scripts": {
"test": "jest",
"test": "jest --passWithNoTests",
"lint": "eslint src"
},
"dependencies": {

View File

@@ -4,7 +4,7 @@
"private": true,
"main": "src/index.ts",
"scripts": {
"test": "jest",
"test": "jest --passWithNoTests",
"lint": "eslint src"
},
"devDependencies": {