@@ -9,7 +9,7 @@ const { ipcRenderer } = require('electron');
99
1010import { SettingsRoute } from './Settings' ;
1111import { AppContext } from '../context/App' ;
12- import { mockSettings } from '../__mocks__/mock-state' ;
12+ import { mockAccounts , mockSettings } from '../__mocks__/mock-state' ;
1313
1414const mockNavigate = jest . fn ( ) ;
1515jest . mock ( 'react-router-dom' , ( ) => ( {
@@ -31,7 +31,9 @@ describe('routes/Settings.tsx', () => {
3131
3232 await act ( async ( ) => {
3333 tree = TestRenderer . create (
34- < AppContext . Provider value = { { settings : mockSettings } } >
34+ < AppContext . Provider
35+ value = { { settings : mockSettings , accounts : mockAccounts } }
36+ >
3537 < MemoryRouter >
3638 < SettingsRoute />
3739 </ MemoryRouter >
@@ -48,7 +50,11 @@ describe('routes/Settings.tsx', () => {
4850 await act ( async ( ) => {
4951 const { getByLabelText : getByLabelTextLocal } = render (
5052 < AppContext . Provider
51- value = { { settings : mockSettings , logout : logoutMock } }
53+ value = { {
54+ settings : mockSettings ,
55+ accounts : mockAccounts ,
56+ logout : logoutMock ,
57+ } }
5258 >
5359 < Router location = { history . location } navigator = { history } >
5460 < SettingsRoute />
@@ -73,7 +79,9 @@ describe('routes/Settings.tsx', () => {
7379
7480 await act ( async ( ) => {
7581 const { getByLabelText : getByLabelTextLocal } = render (
76- < AppContext . Provider value = { { settings : mockSettings } } >
82+ < AppContext . Provider
83+ value = { { settings : mockSettings , accounts : mockAccounts } }
84+ >
7785 < Router location = { history . location } navigator = { history } >
7886 < SettingsRoute />
7987 </ Router >
@@ -91,7 +99,13 @@ describe('routes/Settings.tsx', () => {
9199
92100 await act ( async ( ) => {
93101 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+ >
95109 < MemoryRouter >
96110 < SettingsRoute />
97111 </ MemoryRouter >
@@ -113,7 +127,13 @@ describe('routes/Settings.tsx', () => {
113127
114128 await act ( async ( ) => {
115129 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+ >
117137 < MemoryRouter >
118138 < SettingsRoute />
119139 </ MemoryRouter >
@@ -135,7 +155,13 @@ describe('routes/Settings.tsx', () => {
135155
136156 await act ( async ( ) => {
137157 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+ >
139165 < MemoryRouter >
140166 < SettingsRoute />
141167 </ MemoryRouter >
@@ -157,7 +183,13 @@ describe('routes/Settings.tsx', () => {
157183
158184 await act ( async ( ) => {
159185 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+ >
161193 < MemoryRouter >
162194 < SettingsRoute />
163195 </ MemoryRouter >
@@ -179,7 +211,13 @@ describe('routes/Settings.tsx', () => {
179211
180212 await act ( async ( ) => {
181213 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+ >
183221 < MemoryRouter >
184222 < SettingsRoute />
185223 </ MemoryRouter >
@@ -201,7 +239,13 @@ describe('routes/Settings.tsx', () => {
201239
202240 await act ( async ( ) => {
203241 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+ >
205249 < MemoryRouter >
206250 < SettingsRoute />
207251 </ MemoryRouter >
@@ -221,7 +265,9 @@ describe('routes/Settings.tsx', () => {
221265
222266 await act ( async ( ) => {
223267 const { getByLabelText : getByLabelTextLocal } = render (
224- < AppContext . Provider value = { { settings : mockSettings } } >
268+ < AppContext . Provider
269+ value = { { settings : mockSettings , accounts : mockAccounts } }
270+ >
225271 < Router location = { history . location } navigator = { history } >
226272 < SettingsRoute />
227273 </ Router >
@@ -241,7 +287,9 @@ describe('routes/Settings.tsx', () => {
241287
242288 await act ( async ( ) => {
243289 const { getByLabelText : getByLabelTextLocal } = render (
244- < AppContext . Provider value = { { settings : mockSettings } } >
290+ < AppContext . Provider
291+ value = { { settings : mockSettings , accounts : mockAccounts } }
292+ >
245293 < MemoryRouter >
246294 < SettingsRoute />
247295 </ MemoryRouter >
@@ -253,4 +301,40 @@ describe('routes/Settings.tsx', () => {
253301 fireEvent . click ( getByLabelText ( 'Quit Gitify' ) ) ;
254302 expect ( ipcRenderer . send ) . toHaveBeenCalledWith ( 'app-quit' ) ;
255303 } ) ;
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+ } ) ;
256340} ) ;
0 commit comments