mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 09:30:31 +03:00
Improved VisitsTable test
This commit is contained in:
parent
eabd7d9ecb
commit
859cd9e5e3
2 changed files with 16 additions and 2 deletions
|
@ -150,7 +150,7 @@ const VisitsTable = ({
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{(!resultSet.visitsGroups[page - 1] || resultSet.visitsGroups[page - 1].length === 0) && (
|
{!resultSet.visitsGroups[page - 1]?.length && (
|
||||||
<tr>
|
<tr>
|
||||||
<td colSpan={isOrphanVisits ? 8 : 7} className="text-center">
|
<td colSpan={isOrphanVisits ? 8 : 7} className="text-center">
|
||||||
No visits found with current filtering
|
No visits found with current filtering
|
||||||
|
|
|
@ -10,13 +10,14 @@ describe('<VisitsTable />', () => {
|
||||||
const matchMedia = () => Mock.of<MediaQueryList>({ matches: false });
|
const matchMedia = () => Mock.of<MediaQueryList>({ matches: false });
|
||||||
const setSelectedVisits = jest.fn();
|
const setSelectedVisits = jest.fn();
|
||||||
let wrapper: ShallowWrapper;
|
let wrapper: ShallowWrapper;
|
||||||
const createWrapper = (visits: NormalizedVisit[], selectedVisits: NormalizedVisit[] = []) => {
|
const createWrapper = (visits: NormalizedVisit[], selectedVisits: NormalizedVisit[] = [], isOrphanVisits = false) => {
|
||||||
wrapper = shallow(
|
wrapper = shallow(
|
||||||
<VisitsTable
|
<VisitsTable
|
||||||
visits={visits}
|
visits={visits}
|
||||||
selectedVisits={selectedVisits}
|
selectedVisits={selectedVisits}
|
||||||
setSelectedVisits={setSelectedVisits}
|
setSelectedVisits={setSelectedVisits}
|
||||||
matchMedia={matchMedia}
|
matchMedia={matchMedia}
|
||||||
|
isOrphanVisits={isOrphanVisits}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -134,4 +135,17 @@ describe('<VisitsTable />', () => {
|
||||||
searchField.simulate('change', '');
|
searchField.simulate('change', '');
|
||||||
expect(wrapper.find('tbody').find('tr')).toHaveLength(7 + 2);
|
expect(wrapper.find('tbody').find('tr')).toHaveLength(7 + 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it.each([
|
||||||
|
[ true, 8 ],
|
||||||
|
[ false, 7 ],
|
||||||
|
])('displays proper amount of columns for orphan and non-orphan visits', (isOrphanVisits, expectedCols) => {
|
||||||
|
const wrapper = createWrapper([], [], isOrphanVisits);
|
||||||
|
const rowsWithColspan = wrapper.find('[colSpan]');
|
||||||
|
const cols = wrapper.find('th');
|
||||||
|
|
||||||
|
expect(cols).toHaveLength(expectedCols);
|
||||||
|
expect(rowsWithColspan).toHaveLength(2);
|
||||||
|
rowsWithColspan.forEach((row) => expect(row.prop('colSpan')).toEqual(expectedCols));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue