mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 09:30:31 +03:00
Test proper amount of visits is displayed in TagsList
This commit is contained in:
parent
4ebe23e89f
commit
34cfe2077b
1 changed files with 47 additions and 2 deletions
|
@ -11,14 +11,14 @@ import { renderWithEvents } from '../__helpers__/setUpTest';
|
||||||
describe('<TagsList />', () => {
|
describe('<TagsList />', () => {
|
||||||
const filterTags = jest.fn();
|
const filterTags = jest.fn();
|
||||||
const TagsListComp = createTagsList(({ sortedTags }) => <>TagsTable ({sortedTags.map((t) => t.visits).join(',')})</>);
|
const TagsListComp = createTagsList(({ sortedTags }) => <>TagsTable ({sortedTags.map((t) => t.visits).join(',')})</>);
|
||||||
const setUp = (tagsList: Partial<TagsList>) => renderWithEvents(
|
const setUp = (tagsList: Partial<TagsList>, excludeBots = false) => renderWithEvents(
|
||||||
<TagsListComp
|
<TagsListComp
|
||||||
{...Mock.all<TagsListProps>()}
|
{...Mock.all<TagsListProps>()}
|
||||||
{...Mock.of<MercureBoundProps>({ mercureInfo: {} })}
|
{...Mock.of<MercureBoundProps>({ mercureInfo: {} })}
|
||||||
forceListTags={identity}
|
forceListTags={identity}
|
||||||
filterTags={filterTags}
|
filterTags={filterTags}
|
||||||
tagsList={Mock.of<TagsList>(tagsList)}
|
tagsList={Mock.of<TagsList>(tagsList)}
|
||||||
settings={Mock.all<Settings>()}
|
settings={Mock.of<Settings>({ visits: { excludeBots } })}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -53,4 +53,49 @@ describe('<TagsList />', () => {
|
||||||
await user.type(screen.getByPlaceholderText('Search...'), 'Hello');
|
await user.type(screen.getByPlaceholderText('Search...'), 'Hello');
|
||||||
await waitFor(() => expect(filterTags).toHaveBeenCalledTimes(1));
|
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();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue