Skip to content

Commit fc42614

Browse files
author
Jeffrey Na
committed
Completed Settings Test
1 parent c9e482e commit fc42614

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react';
2+
import { render, fireEvent, screen } from '@testing-library/react';
3+
import Settings from '../../app/components/Settings';
4+
import { DashboardContext } from '../../app/context/DashboardContext';
5+
import '@testing-library/jest-dom';
6+
7+
describe('Settings', () => {
8+
let changeMode = jest.fn();
9+
10+
beforeEach(() => {
11+
render(
12+
<DashboardContext.Provider value={{ changeMode }}>
13+
<Settings />
14+
</DashboardContext.Provider>
15+
);
16+
});
17+
18+
test('Should change mode to light mode on light button click', () => {
19+
fireEvent.click(screen.getByRole('button', { name: 'Light' }));
20+
expect(changeMode).toHaveBeenCalledWith('light');
21+
});
22+
23+
test('Should change mode to dark mode on dark button click', () => {
24+
fireEvent.click(screen.getByRole('button', { name: 'Dark' }));
25+
expect(changeMode).toHaveBeenCalledWith('dark');
26+
});
27+
});

0 commit comments

Comments
 (0)