Skip to content

Commit

Permalink
fix: Refactor Final.test.js to mock useBoundStore and fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
drikusroor committed Feb 15, 2024
1 parent c92c6ab commit d2b7989
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions frontend/src/components/Final/Final.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,24 @@ import { createMemoryHistory } from 'history'

import Final from './Final'; // Adjust the import path as necessary

jest.mock("../../util/stores", () => ({
useBoundStore: (fn) => {
const methods = {
setSession: jest.fn(),
session: 1
}
return fn(methods)
}
}))
// import useBoundStore from "../../util/stores";

// const session = useBoundStore((state) => state.session);

// console.log(session, useBoundStore)

jest.mock('../../util/stores', () => ({
__esModule: true,
default: (fn) => {
const state = {
session: 1,
participant: 'participant-id',
};

return fn(state);
},
useBoundStore: jest.fn()
}));

jest.mock('../../API', () => ({
finalizeSession: jest.fn(),
Expand Down Expand Up @@ -113,7 +122,7 @@ describe('Final Component', () => {
<BrowserRouter>
<Final
participant="participant-id"
session="session-id"
session="session-id"
/>
</BrowserRouter>
);
Expand Down

0 comments on commit d2b7989

Please sign in to comment.