@@ -26,7 +26,11 @@ describe('components/NotificationRow.tsx', () => {
2626 hostname : 'github.com' ,
2727 } ;
2828
29- const tree = render ( < NotificationRow { ...props } /> ) ;
29+ const tree = render (
30+ < AppContext . Provider value = { { settings : mockSettings } } >
31+ < NotificationRow { ...props } />
32+ </ AppContext . Provider > ,
33+ ) ;
3034 expect ( tree ) . toMatchSnapshot ( ) ;
3135 } ) ;
3236
@@ -43,7 +47,11 @@ describe('components/NotificationRow.tsx', () => {
4347 hostname : 'github.com' ,
4448 } ;
4549
46- const tree = render ( < NotificationRow { ...props } /> ) ;
50+ const tree = render (
51+ < AppContext . Provider value = { { settings : mockSettings } } >
52+ < NotificationRow { ...props } />
53+ </ AppContext . Provider > ,
54+ ) ;
4755 expect ( tree ) . toMatchSnapshot ( ) ;
4856 } ) ;
4957
@@ -60,11 +68,42 @@ describe('components/NotificationRow.tsx', () => {
6068 hostname : 'github.com' ,
6169 } ;
6270
63- const tree = render ( < NotificationRow { ...props } /> ) ;
71+ const tree = render (
72+ < AppContext . Provider value = { { settings : mockSettings } } >
73+ < NotificationRow { ...props } />
74+ </ AppContext . Provider > ,
75+ ) ;
6476 expect ( tree ) . toMatchSnapshot ( ) ;
6577 } ) ;
6678
6779 describe ( 'notification pills / metrics' , ( ) => {
80+ describe ( 'showPills disabled' , ( ) => {
81+ it ( 'should not render any pills when showPills is disabled' , async ( ) => {
82+ jest
83+ . spyOn ( global . Date , 'now' )
84+ . mockImplementation ( ( ) => new Date ( '2024' ) . valueOf ( ) ) ;
85+
86+ const mockNotification = mockSingleNotification ;
87+ mockNotification . subject . linkedIssues = [ '#1' ] ;
88+
89+ const props = {
90+ notification : mockNotification ,
91+ hostname : 'github.com' ,
92+ } ;
93+
94+ const tree = render (
95+ < AppContext . Provider
96+ value = { {
97+ settings : { ...mockSettings , showPills : false } ,
98+ } }
99+ >
100+ < NotificationRow { ...props } />
101+ </ AppContext . Provider > ,
102+ ) ;
103+ expect ( tree ) . toMatchSnapshot ( ) ;
104+ } ) ;
105+ } ) ;
106+
68107 describe ( 'linked issue pills' , ( ) => {
69108 it ( 'should render issues pill when linked to one issue/pr' , async ( ) => {
70109 jest
@@ -79,7 +118,15 @@ describe('components/NotificationRow.tsx', () => {
79118 hostname : 'github.com' ,
80119 } ;
81120
82- const tree = render ( < NotificationRow { ...props } /> ) ;
121+ const tree = render (
122+ < AppContext . Provider
123+ value = { {
124+ settings : mockSettings ,
125+ } }
126+ >
127+ < NotificationRow { ...props } />
128+ </ AppContext . Provider > ,
129+ ) ;
83130 expect ( tree ) . toMatchSnapshot ( ) ;
84131 } ) ;
85132
@@ -96,7 +143,15 @@ describe('components/NotificationRow.tsx', () => {
96143 hostname : 'github.com' ,
97144 } ;
98145
99- const tree = render ( < NotificationRow { ...props } /> ) ;
146+ const tree = render (
147+ < AppContext . Provider
148+ value = { {
149+ settings : mockSettings ,
150+ } }
151+ >
152+ < NotificationRow { ...props } />
153+ </ AppContext . Provider > ,
154+ ) ;
100155 expect ( tree ) . toMatchSnapshot ( ) ;
101156 } ) ;
102157 } ) ;
@@ -115,7 +170,15 @@ describe('components/NotificationRow.tsx', () => {
115170 hostname : 'github.com' ,
116171 } ;
117172
118- const tree = render ( < NotificationRow { ...props } /> ) ;
173+ const tree = render (
174+ < AppContext . Provider
175+ value = { {
176+ settings : mockSettings ,
177+ } }
178+ >
179+ < NotificationRow { ...props } />
180+ </ AppContext . Provider > ,
181+ ) ;
119182 expect ( tree ) . toMatchSnapshot ( ) ;
120183 } ) ;
121184
@@ -132,7 +195,15 @@ describe('components/NotificationRow.tsx', () => {
132195 hostname : 'github.com' ,
133196 } ;
134197
135- const tree = render ( < NotificationRow { ...props } /> ) ;
198+ const tree = render (
199+ < AppContext . Provider
200+ value = { {
201+ settings : mockSettings ,
202+ } }
203+ >
204+ < NotificationRow { ...props } />
205+ </ AppContext . Provider > ,
206+ ) ;
136207 expect ( tree ) . toMatchSnapshot ( ) ;
137208 } ) ;
138209
@@ -149,7 +220,15 @@ describe('components/NotificationRow.tsx', () => {
149220 hostname : 'github.com' ,
150221 } ;
151222
152- const tree = render ( < NotificationRow { ...props } /> ) ;
223+ const tree = render (
224+ < AppContext . Provider
225+ value = { {
226+ settings : mockSettings ,
227+ } }
228+ >
229+ < NotificationRow { ...props } />
230+ </ AppContext . Provider > ,
231+ ) ;
153232 expect ( tree ) . toMatchSnapshot ( ) ;
154233 } ) ;
155234 } ) ;
@@ -168,7 +247,15 @@ describe('components/NotificationRow.tsx', () => {
168247 hostname : 'github.com' ,
169248 } ;
170249
171- const tree = render ( < NotificationRow { ...props } /> ) ;
250+ const tree = render (
251+ < AppContext . Provider
252+ value = { {
253+ settings : mockSettings ,
254+ } }
255+ >
256+ < NotificationRow { ...props } />
257+ </ AppContext . Provider > ,
258+ ) ;
172259 expect ( tree ) . toMatchSnapshot ( ) ;
173260 } ) ;
174261 } ) ;
@@ -190,7 +277,15 @@ describe('components/NotificationRow.tsx', () => {
190277 hostname : 'github.com' ,
191278 } ;
192279
193- const tree = render ( < NotificationRow { ...props } /> ) ;
280+ const tree = render (
281+ < AppContext . Provider
282+ value = { {
283+ settings : mockSettings ,
284+ } }
285+ >
286+ < NotificationRow { ...props } />
287+ </ AppContext . Provider > ,
288+ ) ;
194289 expect ( tree ) . toMatchSnapshot ( ) ;
195290 } ) ;
196291
@@ -210,7 +305,15 @@ describe('components/NotificationRow.tsx', () => {
210305 hostname : 'github.com' ,
211306 } ;
212307
213- const tree = render ( < NotificationRow { ...props } /> ) ;
308+ const tree = render (
309+ < AppContext . Provider
310+ value = { {
311+ settings : mockSettings ,
312+ } }
313+ >
314+ < NotificationRow { ...props } />
315+ </ AppContext . Provider > ,
316+ ) ;
214317 expect ( tree ) . toMatchSnapshot ( ) ;
215318 } ) ;
216319 } ) ;
@@ -304,12 +407,10 @@ describe('components/NotificationRow.tsx', () => {
304407 < AppContext . Provider
305408 value = { {
306409 settings : { ...mockSettings , markAsDoneOnOpen : false } ,
307- auth : mockAuth ,
410+ markNotificationRead ,
308411 } }
309412 >
310- < AppContext . Provider value = { { markNotificationRead } } >
311- < NotificationRow { ...props } />
312- </ AppContext . Provider >
413+ < NotificationRow { ...props } />
313414 </ AppContext . Provider > ,
314415 ) ;
315416
@@ -327,14 +428,9 @@ describe('components/NotificationRow.tsx', () => {
327428
328429 render (
329430 < AppContext . Provider
330- value = { {
331- settings : { ...mockSettings } ,
332- auth : mockAuth ,
333- } }
431+ value = { { settings : mockSettings , markNotificationDone } }
334432 >
335- < AppContext . Provider value = { { markNotificationDone } } >
336- < NotificationRow { ...props } />
337- </ AppContext . Provider >
433+ < NotificationRow { ...props } />
338434 </ AppContext . Provider > ,
339435 ) ;
340436
@@ -352,7 +448,9 @@ describe('components/NotificationRow.tsx', () => {
352448
353449 render (
354450 < AppContext . Provider value = { { } } >
355- < AppContext . Provider value = { { unsubscribeNotification } } >
451+ < AppContext . Provider
452+ value = { { settings : mockSettings , unsubscribeNotification } }
453+ >
356454 < NotificationRow { ...props } />
357455 </ AppContext . Provider >
358456 </ AppContext . Provider > ,
0 commit comments