1- import { act , fireEvent , render , screen } from '@testing-library/react' ;
1+ import { act , render , screen } from '@testing-library/react' ;
2+ import userEvent from '@testing-library/user-event' ;
23import { MemoryRouter } from 'react-router-dom' ;
4+
35import { mockAuth , mockSettings } from '../../__mocks__/state-mocks' ;
46import { AppContext } from '../../context/App' ;
57import * as comms from '../../utils/comms' ;
@@ -29,7 +31,7 @@ describe('renderer/components/settings/NotificationSettings.tsx', () => {
2931 ) ;
3032 } ) ;
3133
32- fireEvent . click ( screen . getByTestId ( 'radio-groupBy-date' ) ) ;
34+ await userEvent . click ( screen . getByTestId ( 'radio-groupBy-date' ) ) ;
3335
3436 expect ( updateSetting ) . toHaveBeenCalledTimes ( 1 ) ;
3537 expect ( updateSetting ) . toHaveBeenCalledWith ( 'groupBy' , 'DATE' ) ;
@@ -52,9 +54,7 @@ describe('renderer/components/settings/NotificationSettings.tsx', () => {
5254 ) ;
5355 } ) ;
5456
55- fireEvent . click ( screen . getByTestId ( 'checkbox-fetchAllNotifications' ) , {
56- target : { checked : true } ,
57- } ) ;
57+ await userEvent . click ( screen . getByTestId ( 'checkbox-fetchAllNotifications' ) ) ;
5858
5959 expect ( updateSetting ) . toHaveBeenCalledTimes ( 1 ) ;
6060 expect ( updateSetting ) . toHaveBeenCalledWith ( 'fetchAllNotifications' , false ) ;
@@ -77,7 +77,7 @@ describe('renderer/components/settings/NotificationSettings.tsx', () => {
7777 ) ;
7878 } ) ;
7979
80- fireEvent . click ( screen . getByTestId ( 'checkbox-detailedNotifications' ) ) ;
80+ await userEvent . click ( screen . getByTestId ( 'checkbox-detailedNotifications' ) ) ;
8181
8282 expect ( updateSetting ) . toHaveBeenCalledTimes ( 1 ) ;
8383 expect ( updateSetting ) . toHaveBeenCalledWith ( 'detailedNotifications' , false ) ;
@@ -100,7 +100,7 @@ describe('renderer/components/settings/NotificationSettings.tsx', () => {
100100 ) ;
101101 } ) ;
102102
103- fireEvent . click ( screen . getByTestId ( 'checkbox-showPills' ) ) ;
103+ await userEvent . click ( screen . getByTestId ( 'checkbox-showPills' ) ) ;
104104
105105 expect ( updateSetting ) . toHaveBeenCalledTimes ( 1 ) ;
106106 expect ( updateSetting ) . toHaveBeenCalledWith ( 'showPills' , false ) ;
@@ -123,7 +123,7 @@ describe('renderer/components/settings/NotificationSettings.tsx', () => {
123123 ) ;
124124 } ) ;
125125
126- fireEvent . click ( screen . getByTestId ( 'checkbox-showNumber' ) ) ;
126+ await userEvent . click ( screen . getByTestId ( 'checkbox-showNumber' ) ) ;
127127
128128 expect ( updateSetting ) . toHaveBeenCalledTimes ( 1 ) ;
129129 expect ( updateSetting ) . toHaveBeenCalledWith ( 'showNumber' , false ) ;
@@ -146,12 +146,10 @@ describe('renderer/components/settings/NotificationSettings.tsx', () => {
146146 ) ;
147147 } ) ;
148148
149- fireEvent . click ( screen . getByTestId ( 'checkbox-showOnlyParticipating' ) , {
150- target : { checked : true } ,
151- } ) ;
149+ await userEvent . click ( screen . getByTestId ( 'checkbox-showOnlyParticipating' ) ) ;
152150
153151 expect ( updateSetting ) . toHaveBeenCalledTimes ( 1 ) ;
154- expect ( updateSetting ) . toHaveBeenCalledWith ( 'participating' , false ) ;
152+ expect ( updateSetting ) . toHaveBeenCalledWith ( 'participating' , true ) ;
155153 } ) ;
156154
157155 it ( 'should open official docs for showOnlyParticipating tooltip' , async ( ) => {
@@ -179,9 +177,8 @@ describe('renderer/components/settings/NotificationSettings.tsx', () => {
179177 'tooltip-showOnlyParticipating' ,
180178 ) ;
181179
182- fireEvent . mouseEnter ( tooltipElement ) ;
183-
184- fireEvent . click (
180+ await userEvent . hover ( tooltipElement ) ;
181+ await userEvent . click (
185182 screen . getByTitle (
186183 'Open GitHub documentation for participating and watching notifications' ,
187184 ) ,
@@ -210,12 +207,10 @@ describe('renderer/components/settings/NotificationSettings.tsx', () => {
210207 ) ;
211208 } ) ;
212209
213- fireEvent . click ( screen . getByTestId ( 'checkbox-markAsDoneOnOpen' ) , {
214- target : { checked : true } ,
215- } ) ;
210+ await userEvent . click ( screen . getByTestId ( 'checkbox-markAsDoneOnOpen' ) ) ;
216211
217212 expect ( updateSetting ) . toHaveBeenCalledTimes ( 1 ) ;
218- expect ( updateSetting ) . toHaveBeenCalledWith ( 'markAsDoneOnOpen' , false ) ;
213+ expect ( updateSetting ) . toHaveBeenCalledWith ( 'markAsDoneOnOpen' , true ) ;
219214 } ) ;
220215
221216 it ( 'should toggle the markAsDoneOnUnsubscribe checkbox' , async ( ) => {
@@ -235,15 +230,12 @@ describe('renderer/components/settings/NotificationSettings.tsx', () => {
235230 ) ;
236231 } ) ;
237232
238- fireEvent . click ( screen . getByTestId ( 'checkbox-markAsDoneOnUnsubscribe' ) , {
239- target : { checked : true } ,
240- } ) ;
233+ await userEvent . click (
234+ screen . getByTestId ( 'checkbox-markAsDoneOnUnsubscribe' ) ,
235+ ) ;
241236
242237 expect ( updateSetting ) . toHaveBeenCalledTimes ( 1 ) ;
243- expect ( updateSetting ) . toHaveBeenCalledWith (
244- 'markAsDoneOnUnsubscribe' ,
245- false ,
246- ) ;
238+ expect ( updateSetting ) . toHaveBeenCalledWith ( 'markAsDoneOnUnsubscribe' , true ) ;
247239 } ) ;
248240
249241 it ( 'should toggle the delayNotificationState checkbox' , async ( ) => {
@@ -263,11 +255,11 @@ describe('renderer/components/settings/NotificationSettings.tsx', () => {
263255 ) ;
264256 } ) ;
265257
266- fireEvent . click ( screen . getByTestId ( 'checkbox-delayNotificationState' ) , {
267- target : { checked : true } ,
268- } ) ;
258+ await userEvent . click (
259+ screen . getByTestId ( 'checkbox-delayNotificationState' ) ,
260+ ) ;
269261
270262 expect ( updateSetting ) . toHaveBeenCalledTimes ( 1 ) ;
271- expect ( updateSetting ) . toHaveBeenCalledWith ( 'delayNotificationState' , false ) ;
263+ expect ( updateSetting ) . toHaveBeenCalledWith ( 'delayNotificationState' , true ) ;
272264 } ) ;
273265} ) ;
0 commit comments