Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
myandrienko committed May 21, 2024
1 parent ad0d763 commit ce563b0
Showing 1 changed file with 3 additions and 26 deletions.
29 changes: 3 additions & 26 deletions src/components/Reactions/__tests__/ReactionsListModal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ describe('ReactionsListModal', () => {
love: { count: 5 },
};
const reactions = generateReactionsFromReactionGroups(reactionGroups);
const fetchReactions = jest.fn(() => Promise.resolve(reactions));
const fetchReactions = jest.fn((type) =>
Promise.resolve(reactions.filter((r) => r.type === type)),
);

const { container, getAllByTestId, getByTestId } = renderComponent({
handleFetchReactions: fetchReactions,
Expand Down Expand Up @@ -181,31 +183,6 @@ describe('ReactionsListModal', () => {
).toStrictEqual(Node.DOCUMENT_POSITION_FOLLOWING);
});

it('should order reacted users alphabetically by default', async () => {
const reactionGroups = {
haha: { count: 3 },
};
const reactions = generateReactionsFromReactionGroups(reactionGroups).reverse();
const fetchReactions = jest.fn(() => Promise.resolve(reactions));
const { getByTestId, getByText } = renderComponent({
handleFetchReactions: fetchReactions,
reaction_groups: reactionGroups,
reactions,
});

await act(() => {
fireEvent.click(getByTestId('reactions-list-button-haha'));
});

expect(
getByText('Mark Number 0').compareDocumentPosition(getByText('Mark Number 1')),
).toStrictEqual(Node.DOCUMENT_POSITION_FOLLOWING);

expect(
getByText('Mark Number 1').compareDocumentPosition(getByText('Mark Number 2')),
).toStrictEqual(Node.DOCUMENT_POSITION_FOLLOWING);
});

it('should use custom reaction details comparator if provided', async () => {
const reactionGroups = {
haha: { count: 3 },
Expand Down

0 comments on commit ce563b0

Please sign in to comment.