mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-09 17:57:26 +03:00
Added tests for ordering logic in TagsTable
This commit is contained in:
parent
9cbeef1cb4
commit
39d5853fe3
1 changed files with 22 additions and 0 deletions
|
@ -7,6 +7,7 @@ import { SelectedServer } from '../../src/servers/data';
|
||||||
import { TagsList } from '../../src/tags/reducers/tagsList';
|
import { TagsList } from '../../src/tags/reducers/tagsList';
|
||||||
import { rangeOf } from '../../src/utils/utils';
|
import { rangeOf } from '../../src/utils/utils';
|
||||||
import SimplePaginator from '../../src/common/SimplePaginator';
|
import SimplePaginator from '../../src/common/SimplePaginator';
|
||||||
|
import { NormalizedTag } from '../../src/tags/data';
|
||||||
|
|
||||||
describe('<TagsTable />', () => {
|
describe('<TagsTable />', () => {
|
||||||
const TagsTableRow = () => null;
|
const TagsTableRow = () => null;
|
||||||
|
@ -95,4 +96,25 @@ describe('<TagsTable />', () => {
|
||||||
(wrapper.find(SimplePaginator).prop('setCurrentPage') as Function)(5);
|
(wrapper.find(SimplePaginator).prop('setCurrentPage') as Function)(5);
|
||||||
expect(wrapper.find(SimplePaginator).prop('currentPage')).toEqual(5);
|
expect(wrapper.find(SimplePaginator).prop('currentPage')).toEqual(5);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('orders tags when column is clicked', () => {
|
||||||
|
const wrapper = createWrapper(tags(100));
|
||||||
|
const firstRowText = () => (wrapper.find('tbody').find(TagsTableRow).first().prop('tag') as NormalizedTag).tag;
|
||||||
|
|
||||||
|
expect(firstRowText()).toEqual('tag_1');
|
||||||
|
wrapper.find('thead').find('th').first().simulate('click'); // Tag column ASC
|
||||||
|
expect(firstRowText()).toEqual('tag_1');
|
||||||
|
wrapper.find('thead').find('th').first().simulate('click'); // Tag column DESC
|
||||||
|
expect(firstRowText()).toEqual('tag_99');
|
||||||
|
wrapper.find('thead').find('th').at(2).simulate('click'); // Visits column - ASC
|
||||||
|
expect(firstRowText()).toEqual('tag_100');
|
||||||
|
wrapper.find('thead').find('th').at(2).simulate('click'); // Visits column - DESC
|
||||||
|
expect(firstRowText()).toEqual('tag_1');
|
||||||
|
wrapper.find('thead').find('th').at(2).simulate('click'); // Visits column - reset
|
||||||
|
expect(firstRowText()).toEqual('tag_1');
|
||||||
|
wrapper.find('thead').find('th').at(1).simulate('click'); // Short URLs column - ASC
|
||||||
|
expect(firstRowText()).toEqual('tag_100');
|
||||||
|
wrapper.find('thead').find('th').at(1).simulate('click'); // Short URLs column - DESC
|
||||||
|
expect(firstRowText()).toEqual('tag_1');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue