@@ -29,7 +29,7 @@ describe('hooks/useNotifications.ts', () => {
29
29
. reply ( 200 , notifications ) ;
30
30
31
31
const { result, waitForNextUpdate } = renderHook ( ( ) =>
32
- useNotifications ( )
32
+ useNotifications ( false )
33
33
) ;
34
34
35
35
act ( ( ) => {
@@ -59,7 +59,7 @@ describe('hooks/useNotifications.ts', () => {
59
59
. reply ( 400 , { message } ) ;
60
60
61
61
const { result, waitForNextUpdate } = renderHook ( ( ) =>
62
- useNotifications ( )
62
+ useNotifications ( false )
63
63
) ;
64
64
65
65
act ( ( ) => {
@@ -92,7 +92,7 @@ describe('hooks/useNotifications.ts', () => {
92
92
. reply ( 200 , notifications ) ;
93
93
94
94
const { result, waitForNextUpdate } = renderHook ( ( ) =>
95
- useNotifications ( )
95
+ useNotifications ( false )
96
96
) ;
97
97
98
98
act ( ( ) => {
@@ -118,7 +118,7 @@ describe('hooks/useNotifications.ts', () => {
118
118
. reply ( 400 , { message : 'Oops! Something went wrong.' } ) ;
119
119
120
120
const { result, waitForNextUpdate } = renderHook ( ( ) =>
121
- useNotifications ( )
121
+ useNotifications ( false )
122
122
) ;
123
123
124
124
act ( ( ) => {
@@ -149,7 +149,7 @@ describe('hooks/useNotifications.ts', () => {
149
149
. reply ( 200 , notifications ) ;
150
150
151
151
const { result, waitForNextUpdate } = renderHook ( ( ) =>
152
- useNotifications ( )
152
+ useNotifications ( false )
153
153
) ;
154
154
155
155
act ( ( ) => {
@@ -173,7 +173,7 @@ describe('hooks/useNotifications.ts', () => {
173
173
. reply ( 400 , { message : 'Oops! Something went wrong.' } ) ;
174
174
175
175
const { result, waitForNextUpdate } = renderHook ( ( ) =>
176
- useNotifications ( )
176
+ useNotifications ( false )
177
177
) ;
178
178
179
179
act ( ( ) => {
@@ -185,6 +185,95 @@ describe('hooks/useNotifications.ts', () => {
185
185
expect ( result . current . requestFailed ) . toBe ( true ) ;
186
186
} ) ;
187
187
} ) ;
188
+
189
+ describe ( 'with colors' , ( ) => {
190
+ it ( 'should fetch notifications with success - with colors' , async ( ) => {
191
+ const accounts : AuthState = {
192
+ ...mockAccounts ,
193
+ enterpriseAccounts : [ ] ,
194
+ user : mockedUser ,
195
+ } ;
196
+
197
+ const notifications = [
198
+ {
199
+ id : 1 ,
200
+ title : 'This is a notification.' ,
201
+ subject : { type : 'Issue' , url : 'https://api.github.com/1' } ,
202
+ } ,
203
+ {
204
+ id : 2 ,
205
+ title : 'A merged PR.' ,
206
+ subject : { type : 'PullRequest' , url : 'https://api.github.com/2' } ,
207
+ } ,
208
+ {
209
+ id : 3 ,
210
+ title : 'A closed PR.' ,
211
+ subject : { type : 'PullRequest' , url : 'https://api.github.com/3' } ,
212
+ } ,
213
+ {
214
+ id : 4 ,
215
+ title : 'A draft PR.' ,
216
+ subject : { type : 'PullRequest' , url : 'https://api.github.com/4' } ,
217
+ } ,
218
+ {
219
+ id : 5 ,
220
+ title : 'A draft PR.' ,
221
+ subject : { type : 'PullRequest' , url : 'https://api.github.com/5' } ,
222
+ } ,
223
+ ] ;
224
+
225
+ nock ( 'https://api.github.com' )
226
+ . get ( '/notifications?participating=false' )
227
+ . reply ( 200 , notifications ) ;
228
+
229
+ nock ( 'https://api.github.com' ) . get ( '/1' ) . reply ( 200 , { state : 'open' } ) ;
230
+ nock ( 'https://api.github.com' )
231
+ . get ( '/2' )
232
+ . reply ( 200 , { state : 'closed' , merged : true } ) ;
233
+ nock ( 'https://api.github.com' )
234
+ . get ( '/3' )
235
+ . reply ( 200 , { state : 'closed' , merged : false } ) ;
236
+ nock ( 'https://api.github.com' )
237
+ . get ( '/4' )
238
+ . reply ( 200 , { state : 'open' , draft : false } ) ;
239
+ nock ( 'https://api.github.com' )
240
+ . get ( '/5' )
241
+ . reply ( 200 , { state : 'open' , draft : true } ) ;
242
+
243
+ const { result, waitForNextUpdate } = renderHook ( ( ) =>
244
+ useNotifications ( true )
245
+ ) ;
246
+
247
+ act ( ( ) => {
248
+ result . current . fetchNotifications ( accounts , {
249
+ ...mockSettings ,
250
+ colors : true ,
251
+ } ) ;
252
+ } ) ;
253
+
254
+ expect ( result . current . isFetching ) . toBe ( true ) ;
255
+
256
+ await waitForNextUpdate ( ) ;
257
+
258
+ expect ( result . current . notifications [ 0 ] . hostname ) . toBe ( 'github.com' ) ;
259
+ expect ( result . current . notifications [ 0 ] . notifications . length ) . toBe ( 5 ) ;
260
+ expect (
261
+ result . current . notifications [ 0 ] . notifications [ 0 ] . subject . state
262
+ ) . toBe ( 'open' ) ;
263
+ expect (
264
+ result . current . notifications [ 0 ] . notifications [ 1 ] . subject . state
265
+ ) . toBe ( 'merged' ) ;
266
+ expect (
267
+ result . current . notifications [ 0 ] . notifications [ 2 ] . subject . state
268
+ ) . toBe ( 'closed' ) ;
269
+ expect (
270
+ result . current . notifications [ 0 ] . notifications [ 3 ] . subject . state
271
+ ) . toBe ( 'open' ) ;
272
+ expect (
273
+ result . current . notifications [ 0 ] . notifications [ 4 ] . subject . state
274
+ ) . toBe ( 'draft' ) ;
275
+ } ) ;
276
+ } ) ;
188
277
} ) ;
189
278
190
279
describe ( 'markNotification' , ( ) => {
@@ -200,7 +289,7 @@ describe('hooks/useNotifications.ts', () => {
200
289
. reply ( 200 ) ;
201
290
202
291
const { result, waitForNextUpdate } = renderHook ( ( ) =>
203
- useNotifications ( )
292
+ useNotifications ( false )
204
293
) ;
205
294
206
295
act ( ( ) => {
@@ -218,7 +307,7 @@ describe('hooks/useNotifications.ts', () => {
218
307
. reply ( 400 ) ;
219
308
220
309
const { result, waitForNextUpdate } = renderHook ( ( ) =>
221
- useNotifications ( )
310
+ useNotifications ( false )
222
311
) ;
223
312
224
313
act ( ( ) => {
@@ -241,7 +330,7 @@ describe('hooks/useNotifications.ts', () => {
241
330
. reply ( 200 ) ;
242
331
243
332
const { result, waitForNextUpdate } = renderHook ( ( ) =>
244
- useNotifications ( )
333
+ useNotifications ( false )
245
334
) ;
246
335
247
336
act ( ( ) => {
@@ -259,7 +348,7 @@ describe('hooks/useNotifications.ts', () => {
259
348
. reply ( 400 ) ;
260
349
261
350
const { result, waitForNextUpdate } = renderHook ( ( ) =>
262
- useNotifications ( )
351
+ useNotifications ( false )
263
352
) ;
264
353
265
354
act ( ( ) => {
@@ -292,7 +381,7 @@ describe('hooks/useNotifications.ts', () => {
292
381
. reply ( 200 ) ;
293
382
294
383
const { result, waitForValueToChange } = renderHook ( ( ) =>
295
- useNotifications ( )
384
+ useNotifications ( false )
296
385
) ;
297
386
298
387
act ( ( ) => {
@@ -318,7 +407,7 @@ describe('hooks/useNotifications.ts', () => {
318
407
. reply ( 400 ) ;
319
408
320
409
const { result, waitForValueToChange } = renderHook ( ( ) =>
321
- useNotifications ( )
410
+ useNotifications ( false )
322
411
) ;
323
412
324
413
act ( ( ) => {
@@ -349,7 +438,7 @@ describe('hooks/useNotifications.ts', () => {
349
438
. reply ( 200 ) ;
350
439
351
440
const { result, waitForValueToChange } = renderHook ( ( ) =>
352
- useNotifications ( )
441
+ useNotifications ( false )
353
442
) ;
354
443
355
444
act ( ( ) => {
@@ -375,7 +464,7 @@ describe('hooks/useNotifications.ts', () => {
375
464
. reply ( 400 ) ;
376
465
377
466
const { result, waitForValueToChange } = renderHook ( ( ) =>
378
- useNotifications ( )
467
+ useNotifications ( false )
379
468
) ;
380
469
381
470
act ( ( ) => {
@@ -404,7 +493,7 @@ describe('hooks/useNotifications.ts', () => {
404
493
. reply ( 200 ) ;
405
494
406
495
const { result, waitForNextUpdate } = renderHook ( ( ) =>
407
- useNotifications ( )
496
+ useNotifications ( false )
408
497
) ;
409
498
410
499
act ( ( ) => {
@@ -422,7 +511,7 @@ describe('hooks/useNotifications.ts', () => {
422
511
. reply ( 400 ) ;
423
512
424
513
const { result, waitForNextUpdate } = renderHook ( ( ) =>
425
- useNotifications ( )
514
+ useNotifications ( false )
426
515
) ;
427
516
428
517
act ( ( ) => {
@@ -445,7 +534,7 @@ describe('hooks/useNotifications.ts', () => {
445
534
. reply ( 200 ) ;
446
535
447
536
const { result, waitForNextUpdate } = renderHook ( ( ) =>
448
- useNotifications ( )
537
+ useNotifications ( false )
449
538
) ;
450
539
451
540
act ( ( ) => {
@@ -463,7 +552,7 @@ describe('hooks/useNotifications.ts', () => {
463
552
. reply ( 400 ) ;
464
553
465
554
const { result, waitForNextUpdate } = renderHook ( ( ) =>
466
- useNotifications ( )
555
+ useNotifications ( false )
467
556
) ;
468
557
469
558
act ( ( ) => {
0 commit comments