mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
Fix frontend tests and story shots after code splitting was enabled
This commit is contained in:
@@ -23,18 +23,24 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { LegacyContext, LegacyContextProvider, useLegacyContext } from "./LegacyContext";
|
import { LegacyContext, LegacyContextProvider, useLegacyContext } from "./LegacyContext";
|
||||||
import { FC } from "react";
|
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
|
import { FC } from "react";
|
||||||
import { renderHook } from "@testing-library/react-hooks";
|
import { renderHook } from "@testing-library/react-hooks";
|
||||||
|
import { QueryClient, QueryClientProvider } from "react-query";
|
||||||
|
|
||||||
describe("LegacyContext tests", () => {
|
describe("LegacyContext tests", () => {
|
||||||
|
const queryClient = new QueryClient();
|
||||||
const createWrapper = (context?: LegacyContext): FC => {
|
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", () => {
|
it("should return provided context", () => {
|
||||||
const { result } = renderHook(() => useLegacyContext(), {
|
const { result } = renderHook(() => useLegacyContext(), {
|
||||||
wrapper: createWrapper(),
|
wrapper: createWrapper()
|
||||||
});
|
});
|
||||||
expect(result.current).toBeDefined();
|
expect(result.current).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ export type BaseContext = {
|
|||||||
|
|
||||||
export type LegacyContext = BaseContext & {
|
export type LegacyContext = BaseContext & {
|
||||||
initialize: () => void;
|
initialize: () => void;
|
||||||
|
queryClient?: QueryClient;
|
||||||
};
|
};
|
||||||
|
|
||||||
const Context = createContext<LegacyContext | undefined>(undefined);
|
const Context = createContext<LegacyContext | undefined>(undefined);
|
||||||
|
|||||||
@@ -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
@@ -4,7 +4,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "jest",
|
"test": "jest --passWithNoTests",
|
||||||
"lint": "eslint src"
|
"lint": "eslint src"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "jest",
|
"test": "jest --passWithNoTests",
|
||||||
"lint": "eslint src"
|
"lint": "eslint src"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
Reference in New Issue
Block a user