Skip to content

Commit 7795ed5

Browse files
committed
fix test
1 parent 28fabf2 commit 7795ed5

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

src/test/javascript/spec/component/overview/course-conversations/layout/conversation-messages/conversation-messages.component.spec.ts

+29-8
Original file line numberDiff line numberDiff line change
@@ -408,15 +408,36 @@ examples.forEach((activeConversation) => {
408408
expect(getSourcePostsSpy).toHaveBeenCalled();
409409
expect(getSourceAnswersSpy).toHaveBeenCalled();
410410

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;
417413

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+
}
420441
}));
421442

422443
it('should filter posts to show only pinned posts when showOnlyPinned is true', () => {

0 commit comments

Comments
 (0)