11import { act , fireEvent , render , screen } from '@testing-library/react' ;
2+ import userEvent from '@testing-library/user-event' ;
23import { webFrame } from 'electron' ;
34import { MemoryRouter } from 'react-router-dom' ;
5+
46import {
57 mockAuth ,
68 mockGitHubAppAccount ,
@@ -34,8 +36,10 @@ describe('renderer/components/settings/AppearanceSettings.tsx', () => {
3436 ) ;
3537 } ) ;
3638
37- const select = screen . getByTestId ( 'settings-theme' ) as HTMLSelectElement ;
38- fireEvent . change ( select , { target : { value : 'LIGHT' } } ) ;
39+ await userEvent . selectOptions (
40+ screen . getByTestId ( 'settings-theme' ) ,
41+ 'LIGHT' ,
42+ ) ;
3943
4044 expect ( updateSetting ) . toHaveBeenCalledTimes ( 1 ) ;
4145 expect ( updateSetting ) . toHaveBeenCalledWith ( 'theme' , 'LIGHT' ) ;
@@ -90,32 +94,35 @@ describe('renderer/components/settings/AppearanceSettings.tsx', () => {
9094 ) ;
9195 } ) ;
9296
97+ // Zoom Out
9398 await act ( async ( ) => {
94- fireEvent . click ( screen . getByTestId ( 'settings-zoom-out' ) ) ;
99+ await userEvent . click ( screen . getByTestId ( 'settings-zoom-out' ) ) ;
95100 await zoomTimeout ( ) ;
96- } ) ;
97101
98- expect ( updateSetting ) . toHaveBeenCalledTimes ( 1 ) ;
99- expect ( updateSetting ) . toHaveBeenCalledWith ( 'zoomPercentage' , 90 ) ;
102+ expect ( updateSetting ) . toHaveBeenCalledTimes ( 1 ) ;
103+ expect ( updateSetting ) . toHaveBeenCalledWith ( 'zoomPercentage' , 90 ) ;
104+ } ) ;
100105
101106 await act ( async ( ) => {
102- fireEvent . click ( screen . getByTestId ( 'settings-zoom-out' ) ) ;
107+ await userEvent . click ( screen . getByTestId ( 'settings-zoom-out' ) ) ;
103108 await zoomTimeout ( ) ;
104109
105110 expect ( updateSetting ) . toHaveBeenCalledTimes ( 2 ) ;
106111 expect ( updateSetting ) . toHaveBeenNthCalledWith ( 2 , 'zoomPercentage' , 80 ) ;
107112 } ) ;
108113
114+ // Zoom In
109115 await act ( async ( ) => {
110- fireEvent . click ( screen . getByTestId ( 'settings-zoom-in' ) ) ;
116+ await userEvent . click ( screen . getByTestId ( 'settings-zoom-in' ) ) ;
111117 await zoomTimeout ( ) ;
112118
113119 expect ( updateSetting ) . toHaveBeenCalledTimes ( 3 ) ;
114120 expect ( updateSetting ) . toHaveBeenNthCalledWith ( 3 , 'zoomPercentage' , 90 ) ;
115121 } ) ;
116122
123+ // Zoom Reset
117124 await act ( async ( ) => {
118- fireEvent . click ( screen . getByTestId ( 'settings-zoom-reset' ) ) ;
125+ await userEvent . click ( screen . getByTestId ( 'settings-zoom-reset' ) ) ;
119126 await zoomTimeout ( ) ;
120127
121128 expect ( updateSetting ) . toHaveBeenCalledTimes ( 4 ) ;
@@ -142,7 +149,7 @@ describe('renderer/components/settings/AppearanceSettings.tsx', () => {
142149 ) ;
143150 } ) ;
144151
145- fireEvent . click ( screen . getByTestId ( 'checkbox-showAccountHeader' ) ) ;
152+ await userEvent . click ( screen . getByTestId ( 'checkbox-showAccountHeader' ) ) ;
146153
147154 expect ( updateSetting ) . toHaveBeenCalledTimes ( 1 ) ;
148155 expect ( updateSetting ) . toHaveBeenCalledWith ( 'showAccountHeader' , true ) ;
@@ -167,7 +174,7 @@ describe('renderer/components/settings/AppearanceSettings.tsx', () => {
167174 ) ;
168175 } ) ;
169176
170- fireEvent . click ( screen . getByTestId ( 'checkbox-wrapNotificationTitle' ) ) ;
177+ await userEvent . click ( screen . getByTestId ( 'checkbox-wrapNotificationTitle' ) ) ;
171178
172179 expect ( updateSetting ) . toHaveBeenCalledTimes ( 1 ) ;
173180 expect ( updateSetting ) . toHaveBeenCalledWith ( 'wrapNotificationTitle' , true ) ;
0 commit comments