mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-02-27 04:06:39 +00:00
Added EventSource connection to mercure hub possible
This commit is contained in:
@@ -36,13 +36,13 @@ describe('<ShortUrlsList />', () => {
|
||||
},
|
||||
]
|
||||
}
|
||||
mercureInfo={{ loading: true }}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
listShortUrlsMock.mockReset();
|
||||
resetShortUrlParamsMock.mockReset();
|
||||
jest.resetAllMocks();
|
||||
wrapper && wrapper.unmount();
|
||||
});
|
||||
|
||||
@@ -55,25 +55,19 @@ describe('<ShortUrlsList />', () => {
|
||||
});
|
||||
|
||||
it('should render table header by default', () => {
|
||||
expect(wrapper.find('table').shallow().find('thead')).toHaveLength(1);
|
||||
expect(wrapper.find('table').find('thead')).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('should render 6 table header cells by default', () => {
|
||||
expect(wrapper.find('table').shallow()
|
||||
.find('thead').shallow()
|
||||
.find('tr').shallow()
|
||||
.find('th')).toHaveLength(6);
|
||||
expect(wrapper.find('table').find('thead').find('tr').find('th')).toHaveLength(6);
|
||||
});
|
||||
|
||||
it('should render 6 table header cells without order by icon by default', () => {
|
||||
const thElements = wrapper.find('table').shallow()
|
||||
.find('thead').shallow()
|
||||
.find('tr').shallow()
|
||||
.find('th').map((e) => e.shallow());
|
||||
const thElements = wrapper.find('table').find('thead').find('tr').find('th');
|
||||
|
||||
for (const thElement of thElements) {
|
||||
thElements.forEach((thElement) => {
|
||||
expect(thElement.find(FontAwesomeIcon)).toHaveLength(0);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should render 6 table header cells with conditional order by icon', () => {
|
||||
@@ -81,40 +75,31 @@ describe('<ShortUrlsList />', () => {
|
||||
ASC: caretUpIcon,
|
||||
DESC: caretDownIcon,
|
||||
};
|
||||
const getThElementForSortableField = (sortableField) => wrapper.find('table')
|
||||
.find('thead')
|
||||
.find('tr')
|
||||
.find('th')
|
||||
.filterWhere((e) => e.text().includes(SORTABLE_FIELDS[sortableField]));
|
||||
|
||||
for (const sortableField of Object.getOwnPropertyNames(SORTABLE_FIELDS)) {
|
||||
wrapper.setState({ orderField: sortableField, orderDir: undefined });
|
||||
const [ sortableThElement ] = wrapper.find('table').shallow()
|
||||
.find('thead').shallow()
|
||||
.find('tr').shallow()
|
||||
.find('th')
|
||||
.filterWhere(
|
||||
(e) =>
|
||||
e.text().includes(SORTABLE_FIELDS[sortableField])
|
||||
);
|
||||
|
||||
const sortableThElementWrapper = shallow(sortableThElement);
|
||||
Object.keys(SORTABLE_FIELDS).forEach((sortableField) => {
|
||||
const sortableThElementWrapper = getThElementForSortableField(sortableField);
|
||||
|
||||
expect(sortableThElementWrapper.find(FontAwesomeIcon)).toHaveLength(0);
|
||||
|
||||
for (const orderDir of Object.getOwnPropertyNames(orderDirOptionToIconMap)) {
|
||||
wrapper.setState({ orderField: sortableField, orderDir });
|
||||
const [ sortableThElement ] = wrapper.find('table').shallow()
|
||||
.find('thead').shallow()
|
||||
.find('tr').shallow()
|
||||
.find('th')
|
||||
.filterWhere(
|
||||
(e) =>
|
||||
e.text().includes(SORTABLE_FIELDS[sortableField])
|
||||
);
|
||||
sortableThElementWrapper.simulate('click');
|
||||
expect(getThElementForSortableField(sortableField).find(FontAwesomeIcon)).toHaveLength(1);
|
||||
expect(getThElementForSortableField(sortableField).find(FontAwesomeIcon).prop('icon')).toEqual(
|
||||
orderDirOptionToIconMap.ASC,
|
||||
);
|
||||
|
||||
const sortableThElementWrapper = shallow(sortableThElement);
|
||||
sortableThElementWrapper.simulate('click');
|
||||
expect(getThElementForSortableField(sortableField).find(FontAwesomeIcon)).toHaveLength(1);
|
||||
expect(getThElementForSortableField(sortableField).find(FontAwesomeIcon).prop('icon')).toEqual(
|
||||
orderDirOptionToIconMap.DESC,
|
||||
);
|
||||
|
||||
expect(sortableThElementWrapper.find(FontAwesomeIcon)).toHaveLength(1);
|
||||
expect(
|
||||
sortableThElementWrapper.find(FontAwesomeIcon).prop('icon')
|
||||
).toEqual(orderDirOptionToIconMap[orderDir]);
|
||||
}
|
||||
}
|
||||
sortableThElementWrapper.simulate('click');
|
||||
expect(sortableThElementWrapper.find(FontAwesomeIcon)).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user