@@ -9,7 +9,8 @@ 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' ;
13+ import Constants from '../utils/constants' ;
1314
1415const mockNavigate = jest . fn ( ) ;
1516jest . mock ( 'react-router-dom' , ( ) => ( {
@@ -31,7 +32,9 @@ describe('routes/Settings.tsx', () => {
3132
3233 await act ( async ( ) => {
3334 tree = TestRenderer . create (
34- < AppContext . Provider value = { { settings : mockSettings } } >
35+ < AppContext . Provider
36+ value = { { settings : mockSettings , accounts : mockAccounts } }
37+ >
3538 < MemoryRouter >
3639 < SettingsRoute />
3740 </ MemoryRouter >
@@ -48,7 +51,11 @@ describe('routes/Settings.tsx', () => {
4851 await act ( async ( ) => {
4952 const { getByLabelText : getByLabelTextLocal } = render (
5053 < AppContext . Provider
51- value = { { settings : mockSettings , logout : logoutMock } }
54+ value = { {
55+ settings : mockSettings ,
56+ accounts : mockAccounts ,
57+ logout : logoutMock ,
58+ } }
5259 >
5360 < Router location = { history . location } navigator = { history } >
5461 < SettingsRoute />
@@ -73,7 +80,9 @@ describe('routes/Settings.tsx', () => {
7380
7481 await act ( async ( ) => {
7582 const { getByLabelText : getByLabelTextLocal } = render (
76- < AppContext . Provider value = { { settings : mockSettings } } >
83+ < AppContext . Provider
84+ value = { { settings : mockSettings , accounts : mockAccounts } }
85+ >
7786 < Router location = { history . location } navigator = { history } >
7887 < SettingsRoute />
7988 </ Router >
@@ -91,7 +100,13 @@ describe('routes/Settings.tsx', () => {
91100
92101 await act ( async ( ) => {
93102 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+ >
95110 < MemoryRouter >
96111 < SettingsRoute />
97112 </ MemoryRouter >
@@ -113,7 +128,13 @@ describe('routes/Settings.tsx', () => {
113128
114129 await act ( async ( ) => {
115130 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+ >
117138 < MemoryRouter >
118139 < SettingsRoute />
119140 </ MemoryRouter >
@@ -135,7 +156,13 @@ describe('routes/Settings.tsx', () => {
135156
136157 await act ( async ( ) => {
137158 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+ >
139166 < MemoryRouter >
140167 < SettingsRoute />
141168 </ MemoryRouter >
@@ -157,7 +184,13 @@ describe('routes/Settings.tsx', () => {
157184
158185 await act ( async ( ) => {
159186 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+ >
161194 < MemoryRouter >
162195 < SettingsRoute />
163196 </ MemoryRouter >
@@ -179,7 +212,13 @@ describe('routes/Settings.tsx', () => {
179212
180213 await act ( async ( ) => {
181214 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+ >
183222 < MemoryRouter >
184223 < SettingsRoute />
185224 </ MemoryRouter >
@@ -201,7 +240,13 @@ describe('routes/Settings.tsx', () => {
201240
202241 await act ( async ( ) => {
203242 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+ >
205250 < MemoryRouter >
206251 < SettingsRoute />
207252 </ MemoryRouter >
@@ -221,7 +266,9 @@ describe('routes/Settings.tsx', () => {
221266
222267 await act ( async ( ) => {
223268 const { getByLabelText : getByLabelTextLocal } = render (
224- < AppContext . Provider value = { { settings : mockSettings } } >
269+ < AppContext . Provider
270+ value = { { settings : mockSettings , accounts : mockAccounts } }
271+ >
225272 < Router location = { history . location } navigator = { history } >
226273 < SettingsRoute />
227274 </ Router >
@@ -241,7 +288,9 @@ describe('routes/Settings.tsx', () => {
241288
242289 await act ( async ( ) => {
243290 const { getByLabelText : getByLabelTextLocal } = render (
244- < AppContext . Provider value = { { settings : mockSettings } } >
291+ < AppContext . Provider
292+ value = { { settings : mockSettings , accounts : mockAccounts } }
293+ >
245294 < MemoryRouter >
246295 < SettingsRoute />
247296 </ MemoryRouter >
@@ -253,4 +302,40 @@ describe('routes/Settings.tsx', () => {
253302 fireEvent . click ( getByLabelText ( 'Quit Gitify' ) ) ;
254303 expect ( ipcRenderer . send ) . toHaveBeenCalledWith ( 'app-quit' ) ;
255304 } ) ;
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+ } ) ;
256341} ) ;
0 commit comments