File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments