Skip to content

Commit

Permalink
resolved conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
asliayk committed Dec 9, 2024
1 parent 972b2b9 commit d5e0e6d
Showing 1 changed file with 24 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ describe('PostFooterComponent', () => {
runInInjectionContext(injector, () => {
component.sortedAnswerPosts = input<AnswerPost[]>(unsortedAnswerArray);
component.groupAnswerPosts();
expect(component.groupedAnswerPosts.length).toBeGreaterThan(0); // Ensure groups are created
expect(component.groupedAnswerPosts[0].posts.length).toBeGreaterThan(0); // Ensure posts exist in groups
expect(component.groupedAnswerPosts.length).toBeGreaterThan(0);
expect(component.groupedAnswerPosts[0].posts.length).toBeGreaterThan(0);
});
});

Expand Down Expand Up @@ -189,27 +189,28 @@ describe('PostFooterComponent', () => {
const post3: AnswerPost = { id: 3, author: authorA, creationDate: baseTime.add(10, 'minute').toDate() } as unknown as AnswerPost;
const post4: AnswerPost = { id: 4, author: authorB, creationDate: baseTime.add(12, 'minute').toDate() } as unknown as AnswerPost;
const post5: AnswerPost = { id: 5, author: authorB, creationDate: baseTime.add(14, 'minute').toDate() } as unknown as AnswerPost;
runInInjectionContext(injector, () => {
component.sortedAnswerPosts = input<AnswerPost[]>([post3, post1, post5, post2, post4]);

component.sortedAnswerPosts = [post3, post1, post5, post2, post4];

component.groupAnswerPosts();
expect(component.groupedAnswerPosts).toHaveLength(3);

const group1 = component.groupedAnswerPosts[0];
expect(group1.author).toEqual(authorA);
expect(group1.posts).toHaveLength(2);
expect(group1.posts).toContainEqual(expect.objectContaining({ id: post1.id }));
expect(group1.posts).toContainEqual(expect.objectContaining({ id: post2.id }));

const group2 = component.groupedAnswerPosts[1];
expect(group2.author).toEqual(authorA);
expect(group2.posts).toHaveLength(1);
expect(group2.posts).toContainEqual(expect.objectContaining({ id: post3.id }));

const group3 = component.groupedAnswerPosts[2];
expect(group3.author).toEqual(authorB);
expect(group3.posts).toHaveLength(2);
expect(group3.posts).toContainEqual(expect.objectContaining({ id: post4.id }));
expect(group3.posts).toContainEqual(expect.objectContaining({ id: post5.id }));
component.groupAnswerPosts();
expect(component.groupedAnswerPosts).toHaveLength(3);

const group1 = component.groupedAnswerPosts[0];
expect(group1.author).toEqual(authorA);
expect(group1.posts).toHaveLength(2);
expect(group1.posts).toContainEqual(expect.objectContaining({ id: post1.id }));
expect(group1.posts).toContainEqual(expect.objectContaining({ id: post2.id }));

const group2 = component.groupedAnswerPosts[1];
expect(group2.author).toEqual(authorA);
expect(group2.posts).toHaveLength(1);
expect(group2.posts).toContainEqual(expect.objectContaining({ id: post3.id }));

const group3 = component.groupedAnswerPosts[2];
expect(group3.author).toEqual(authorB);
expect(group3.posts).toHaveLength(2);
expect(group3.posts).toContainEqual(expect.objectContaining({ id: post4.id }));
expect(group3.posts).toContainEqual(expect.objectContaining({ id: post5.id }));
});
});
});

0 comments on commit d5e0e6d

Please sign in to comment.