Skip to content

Commit

Permalink
fix RichTextWidget tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mnholtz committed Nov 14, 2024
1 parent b7fd1b8 commit 66f3adf
Showing 1 changed file with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,26 @@ import CustomFormComponent, {
type CustomFormComponentProps,
} from "@/bricks/renderers/CustomFormComponent";
import { type Schema } from "@/types/schemaTypes";
import { Provider } from "react-redux";
import { configureStore } from "@reduxjs/toolkit";
import { appApi } from "@/data/service/api";
import { s3UploadApi } from "@/components/richTextEditor/toolbar/ImageButton/useUploadAsset";

describe("RichTextWidget", () => {
const user = userEvent.setup({
// 20ms delay between key presses to allow the editor state to update
// before the next key press
delay: 20,
});

const createTestStore = () =>
configureStore({
reducer: {
appApi: appApi.reducer,
s3UploadApi: s3UploadApi.reducer,
},
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware().concat(appApi.middleware),
});

const createSchema = (properties: Record<string, any>): Schema => ({
type: "object",
properties,
Expand All @@ -48,15 +60,19 @@ describe("RichTextWidget", () => {
}: Pick<CustomFormComponentProps, "schema" | "uiSchema" | "formData"> & {
onSubmit?: jest.Mock;
}) => {
const store = createTestStore();

render(
<CustomFormComponent
schema={schema}
formData={formData}
uiSchema={uiSchema}
submitCaption="Submit"
autoSave={false}
onSubmit={onSubmit}
/>,
<Provider store={store}>
<CustomFormComponent
schema={schema}
formData={formData}
uiSchema={uiSchema}
submitCaption="Submit"
autoSave={false}
onSubmit={onSubmit}
/>
</Provider>,
);
return { onSubmit };
};
Expand Down

0 comments on commit 66f3adf

Please sign in to comment.