@@ -408,15 +408,36 @@ examples.forEach((activeConversation) => {
408
408
expect ( getSourcePostsSpy ) . toHaveBeenCalled ( ) ;
409
409
expect ( getSourceAnswersSpy ) . toHaveBeenCalled ( ) ;
410
410
411
- expect ( component . posts ) . toHaveLength ( 1 ) ;
412
- expect ( component . posts [ 0 ] . forwardedPosts ) . toBeDefined ( ) ;
413
- expect ( component . posts [ 0 ] . forwardedAnswerPosts ) . toBeDefined ( ) ;
414
-
415
- expect ( component . posts [ 0 ] . forwardedPosts ! ) . toHaveLength ( mockSourcePosts . length ) ;
416
- expect ( component . posts [ 0 ] . forwardedAnswerPosts ! ) . toHaveLength ( mockSourceAnswerPosts . length ) ;
411
+ const forwardedPosts = component . posts [ 0 ] . forwardedPosts ;
412
+ const forwardedAnswerPosts = component . posts [ 0 ] . forwardedAnswerPosts ;
417
413
418
- expect ( component . posts [ 0 ] . forwardedPosts ! [ 0 ] . id ) . toBe ( 10 ) ;
419
- expect ( component . posts [ 0 ] . forwardedAnswerPosts ! [ 0 ] . id ) . toBe ( 11 ) ;
414
+ expect ( component . posts ) . toHaveLength ( 1 ) ;
415
+ expect ( forwardedPosts ) . toBeDefined ( ) ;
416
+ expect ( forwardedAnswerPosts ) . toBeDefined ( ) ;
417
+
418
+ if ( forwardedPosts ) {
419
+ expect ( forwardedPosts ) . toHaveLength ( mockSourcePosts . length ) ;
420
+ forwardedPosts . forEach ( ( post ) => {
421
+ if ( post ) {
422
+ expect ( post . id ) . toBeDefined ( ) ;
423
+ expect ( post . id ) . toBe ( 10 ) ;
424
+ } else {
425
+ expect ( post ) . toBeNull ( ) ;
426
+ }
427
+ } ) ;
428
+ }
429
+
430
+ if ( forwardedAnswerPosts ) {
431
+ expect ( forwardedAnswerPosts ) . toHaveLength ( mockSourceAnswerPosts . length ) ;
432
+ forwardedAnswerPosts . forEach ( ( post ) => {
433
+ if ( post ) {
434
+ expect ( post . id ) . toBeDefined ( ) ;
435
+ expect ( post . id ) . toBe ( 11 ) ;
436
+ } else {
437
+ expect ( post ) . toBeNull ( ) ;
438
+ }
439
+ } ) ;
440
+ }
420
441
} ) ) ;
421
442
422
443
it ( 'should filter posts to show only pinned posts when showOnlyPinned is true' , ( ) => {
0 commit comments