Skip to content

Commit e95577e

Browse files
Merge pull request #2164 from OneCommunityGlobal/Shereen_unit_test_weeklySummary_weeklySummaryModal
Shereen unit test weekly summary modal
2 parents 6cc06ed + 46f9aa7 commit e95577e

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import React from 'react';
2+
import { shallow } from 'enzyme';
3+
import { render, screen, waitFor, fireEvent} from '@testing-library/react';
4+
import userEvent from '@testing-library/user-event'
5+
import WeeklySummaryModal from '../WeeklySummaryModal';
6+
import configureMockStore from "redux-mock-store";
7+
import { Provider } from "react-redux";
8+
import mockState from '../../../__tests__/mockAdminState.js';
9+
import { themeMock } from '__tests__/mockStates';
10+
import thunk from 'redux-thunk';
11+
12+
const mockStore = configureMockStore([thunk]);
13+
const store = mockStore({
14+
auth: mockState.auth,
15+
userProfile: mockState.userProfile,
16+
timeEntries: mockState.timeEntries,
17+
userProjects: mockState.userProjects,
18+
weeklySummaries: mockState.weeklySummaries,
19+
role: mockState.role,
20+
theme: themeMock,
21+
});
22+
23+
describe('WeeklySummaryModal Component', () => {
24+
25+
it('should render the component without errors', () => {
26+
const wrapper = shallow(
27+
<Provider store={store}>
28+
<WeeklySummaryModal />
29+
</Provider>
30+
);
31+
expect(wrapper.exists()).toBe(true);
32+
});
33+
34+
it('should toggle the modal when clicked', async () => {
35+
render(
36+
<Provider store={store}>
37+
<WeeklySummaryModal />
38+
</Provider>
39+
);
40+
41+
// The button/div that triggers the modal toggle
42+
const triggerElement = screen.getByRole('button', { name: /toggle weekly summary/i });
43+
44+
// Initial state: Modal should not be in the document
45+
expect(screen.queryByText(/weekly summary/i)).not.toBeInTheDocument();
46+
47+
});
48+
49+
});

0 commit comments

Comments
 (0)