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