@@ -9,7 +9,7 @@ const { ipcRenderer } = require('electron');
9
9
10
10
import { SettingsRoute } from './Settings' ;
11
11
import { AppContext } from '../context/App' ;
12
- import { mockSettings } from '../__mocks__/mock-state' ;
12
+ import { mockAccounts , mockSettings } from '../__mocks__/mock-state' ;
13
13
14
14
const mockNavigate = jest . fn ( ) ;
15
15
jest . mock ( 'react-router-dom' , ( ) => ( {
@@ -31,7 +31,9 @@ describe('routes/Settings.tsx', () => {
31
31
32
32
await act ( async ( ) => {
33
33
tree = TestRenderer . create (
34
- < AppContext . Provider value = { { settings : mockSettings } } >
34
+ < AppContext . Provider
35
+ value = { { settings : mockSettings , accounts : mockAccounts } }
36
+ >
35
37
< MemoryRouter >
36
38
< SettingsRoute />
37
39
</ MemoryRouter >
@@ -48,7 +50,11 @@ describe('routes/Settings.tsx', () => {
48
50
await act ( async ( ) => {
49
51
const { getByLabelText : getByLabelTextLocal } = render (
50
52
< AppContext . Provider
51
- value = { { settings : mockSettings , logout : logoutMock } }
53
+ value = { {
54
+ settings : mockSettings ,
55
+ accounts : mockAccounts ,
56
+ logout : logoutMock ,
57
+ } }
52
58
>
53
59
< Router location = { history . location } navigator = { history } >
54
60
< SettingsRoute />
@@ -73,7 +79,9 @@ describe('routes/Settings.tsx', () => {
73
79
74
80
await act ( async ( ) => {
75
81
const { getByLabelText : getByLabelTextLocal } = render (
76
- < AppContext . Provider value = { { settings : mockSettings } } >
82
+ < AppContext . Provider
83
+ value = { { settings : mockSettings , accounts : mockAccounts } }
84
+ >
77
85
< Router location = { history . location } navigator = { history } >
78
86
< SettingsRoute />
79
87
</ Router >
@@ -91,7 +99,13 @@ describe('routes/Settings.tsx', () => {
91
99
92
100
await act ( async ( ) => {
93
101
const { getByLabelText : getByLabelTextLocal } = render (
94
- < AppContext . Provider value = { { settings : mockSettings , updateSetting } } >
102
+ < AppContext . Provider
103
+ value = { {
104
+ settings : mockSettings ,
105
+ accounts : mockAccounts ,
106
+ updateSetting,
107
+ } }
108
+ >
95
109
< MemoryRouter >
96
110
< SettingsRoute />
97
111
</ MemoryRouter >
@@ -113,7 +127,13 @@ describe('routes/Settings.tsx', () => {
113
127
114
128
await act ( async ( ) => {
115
129
const { getByLabelText : getByLabelTextLocal } = render (
116
- < AppContext . Provider value = { { settings : mockSettings , updateSetting } } >
130
+ < AppContext . Provider
131
+ value = { {
132
+ settings : mockSettings ,
133
+ accounts : mockAccounts ,
134
+ updateSetting,
135
+ } }
136
+ >
117
137
< MemoryRouter >
118
138
< SettingsRoute />
119
139
</ MemoryRouter >
@@ -135,7 +155,13 @@ describe('routes/Settings.tsx', () => {
135
155
136
156
await act ( async ( ) => {
137
157
const { getByLabelText : getByLabelTextLocal } = render (
138
- < AppContext . Provider value = { { settings : mockSettings , updateSetting } } >
158
+ < AppContext . Provider
159
+ value = { {
160
+ settings : mockSettings ,
161
+ accounts : mockAccounts ,
162
+ updateSetting,
163
+ } }
164
+ >
139
165
< MemoryRouter >
140
166
< SettingsRoute />
141
167
</ MemoryRouter >
@@ -157,7 +183,13 @@ describe('routes/Settings.tsx', () => {
157
183
158
184
await act ( async ( ) => {
159
185
const { getByLabelText : getByLabelTextLocal } = render (
160
- < AppContext . Provider value = { { settings : mockSettings , updateSetting } } >
186
+ < AppContext . Provider
187
+ value = { {
188
+ settings : mockSettings ,
189
+ accounts : mockAccounts ,
190
+ updateSetting,
191
+ } }
192
+ >
161
193
< MemoryRouter >
162
194
< SettingsRoute />
163
195
</ MemoryRouter >
@@ -179,7 +211,13 @@ describe('routes/Settings.tsx', () => {
179
211
180
212
await act ( async ( ) => {
181
213
const { getByLabelText : getByLabelTextLocal } = render (
182
- < AppContext . Provider value = { { settings : mockSettings , updateSetting } } >
214
+ < AppContext . Provider
215
+ value = { {
216
+ settings : mockSettings ,
217
+ accounts : mockAccounts ,
218
+ updateSetting,
219
+ } }
220
+ >
183
221
< MemoryRouter >
184
222
< SettingsRoute />
185
223
</ MemoryRouter >
@@ -201,7 +239,13 @@ describe('routes/Settings.tsx', () => {
201
239
202
240
await act ( async ( ) => {
203
241
const { getByLabelText : getByLabelTextLocal } = render (
204
- < AppContext . Provider value = { { settings : mockSettings , updateSetting } } >
242
+ < AppContext . Provider
243
+ value = { {
244
+ settings : mockSettings ,
245
+ accounts : mockAccounts ,
246
+ updateSetting,
247
+ } }
248
+ >
205
249
< MemoryRouter >
206
250
< SettingsRoute />
207
251
</ MemoryRouter >
@@ -221,7 +265,9 @@ describe('routes/Settings.tsx', () => {
221
265
222
266
await act ( async ( ) => {
223
267
const { getByLabelText : getByLabelTextLocal } = render (
224
- < AppContext . Provider value = { { settings : mockSettings } } >
268
+ < AppContext . Provider
269
+ value = { { settings : mockSettings , accounts : mockAccounts } }
270
+ >
225
271
< Router location = { history . location } navigator = { history } >
226
272
< SettingsRoute />
227
273
</ Router >
@@ -241,7 +287,9 @@ describe('routes/Settings.tsx', () => {
241
287
242
288
await act ( async ( ) => {
243
289
const { getByLabelText : getByLabelTextLocal } = render (
244
- < AppContext . Provider value = { { settings : mockSettings } } >
290
+ < AppContext . Provider
291
+ value = { { settings : mockSettings , accounts : mockAccounts } }
292
+ >
245
293
< MemoryRouter >
246
294
< SettingsRoute />
247
295
</ MemoryRouter >
@@ -253,4 +301,40 @@ describe('routes/Settings.tsx', () => {
253
301
fireEvent . click ( getByLabelText ( 'Quit Gitify' ) ) ;
254
302
expect ( ipcRenderer . send ) . toHaveBeenCalledWith ( 'app-quit' ) ;
255
303
} ) ;
304
+
305
+ it ( 'should not be able to disable colors' , async ( ) => {
306
+ let queryByLabelText ;
307
+ jest . mock ( '../utils/helpers' , ( ) => ( {
308
+ ...jest . requireActual ( '../utils/helpers' ) ,
309
+ apiRequestAuth : jest . fn ( ) . mockResolvedValue ( {
310
+ headers : {
311
+ 'x-oauth-scopes' : 'repo, notifications' ,
312
+ } ,
313
+ } ) ,
314
+ } ) ) ;
315
+
316
+ await act ( async ( ) => {
317
+ const { queryByLabelText : queryByLabelLocal } = render (
318
+ < AppContext . Provider
319
+ value = { {
320
+ settings : mockSettings ,
321
+ accounts : mockAccounts ,
322
+ } }
323
+ >
324
+ < MemoryRouter >
325
+ < SettingsRoute />
326
+ </ MemoryRouter >
327
+ </ AppContext . Provider > ,
328
+ ) ;
329
+ queryByLabelText = queryByLabelLocal ;
330
+ } ) ;
331
+
332
+ console . log (
333
+ queryByLabelText ( 'Use GitHub-like state colors (requires re-auth)' ) ,
334
+ ) ;
335
+
336
+ expect (
337
+ queryByLabelText ( 'Use GitHub-like state colors (requires re-auth)' ) ,
338
+ ) . toBeDefined ( ) ;
339
+ } ) ;
256
340
} ) ;
0 commit comments