Skip to content

Commit

Permalink
update msmState factory
Browse files Browse the repository at this point in the history
  • Loading branch information
petermakowski committed Jun 12, 2024
1 parent d003e62 commit 5cefb34
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/testing/factories/msm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ const msmStatus = define<MsmStatus>({
export const msm = define<MsmState>({
status: msmStatus(),
loading: false,
loaded: false,
errors: null,
});
1 change: 1 addition & 0 deletions src/testing/factories/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ export const msmStatus = define<MsmStatus>({
export const msmState = define<MsmState>({
status: msmStatus(),
loading: false,
loaded: false,
errors: null,
});

Expand Down
7 changes: 6 additions & 1 deletion src/testing/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,14 @@ export const renderWithMockStore = (
rerender: (ui: React.ReactNode, newOptions?: WithStoreRenderOptions) => void;
} => {
const { state, store, ...renderOptions } = options ?? {};
const initialState =
typeof state === "function"
? produce(rootStateFactory(), state)
: state || rootStateFactory();

const rendered = render(ui, {
wrapper: (props) => (
<WithMockStoreProvider {...props} state={state} store={store} />
<WithMockStoreProvider {...props} state={initialState} store={store} />
),
...renderOptions,
});
Expand Down

0 comments on commit 5cefb34

Please sign in to comment.