diff --git a/test/tags/TagsList.test.tsx b/test/tags/TagsList.test.tsx index 64dd7afa..19f59b25 100644 --- a/test/tags/TagsList.test.tsx +++ b/test/tags/TagsList.test.tsx @@ -11,14 +11,14 @@ import { renderWithEvents } from '../__helpers__/setUpTest'; describe('', () => { const filterTags = jest.fn(); const TagsListComp = createTagsList(({ sortedTags }) => <>TagsTable ({sortedTags.map((t) => t.visits).join(',')})); - const setUp = (tagsList: Partial) => renderWithEvents( + const setUp = (tagsList: Partial, excludeBots = false) => renderWithEvents( ()} {...Mock.of({ mercureInfo: {} })} forceListTags={identity} filterTags={filterTags} tagsList={Mock.of(tagsList)} - settings={Mock.all()} + settings={Mock.of({ visits: { excludeBots } })} />, ); @@ -53,4 +53,49 @@ describe('', () => { await user.type(screen.getByPlaceholderText('Search...'), 'Hello'); await waitFor(() => expect(filterTags).toHaveBeenCalledTimes(1)); }); + + it.each([ + [false, undefined, '25,25,25'], + [true, undefined, '25,25,25'], + [ + false, + { + total: 20, + nonBots: 15, + bots: 5, + }, + '20,20,20', + ], + [ + true, + { + total: 20, + nonBots: 15, + bots: 5, + }, + '15,15,15', + ], + ])('displays proper amount of visits', (excludeBots, visitsSummary, expectedAmounts) => { + setUp({ + filteredTags: ['foo', 'bar', 'baz'], + stats: { + foo: { + visitsSummary, + visitsCount: 25, + shortUrlsCount: 1, + }, + bar: { + visitsSummary, + visitsCount: 25, + shortUrlsCount: 1, + }, + baz: { + visitsSummary, + visitsCount: 25, + shortUrlsCount: 1, + }, + }, + }, excludeBots); + expect(screen.getByText(`TagsTable (${expectedAmounts})`)).toBeInTheDocument(); + }); });