mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-03 22:31:52 +00:00
Added automatic refresh on mercure events
This commit is contained in:
@@ -20,7 +20,9 @@ describe('<ShortUrlVisitsCount />', () => {
|
||||
const maxVisitsHelper = wrapper.find('.short-urls-visits-count__max-visits-control');
|
||||
const maxVisitsTooltip = wrapper.find(UncontrolledTooltip);
|
||||
|
||||
expect(wrapper.html()).toEqual(`<span><strong>${visitsCount}</strong></span>`);
|
||||
expect(wrapper.html()).toEqual(
|
||||
`<span><strong class="short-url-visits-count__amount">${visitsCount}</strong></span>`
|
||||
);
|
||||
expect(maxVisitsHelper).toHaveLength(0);
|
||||
expect(maxVisitsTooltip).toHaveLength(0);
|
||||
});
|
||||
|
||||
@@ -26,7 +26,9 @@ describe('<VisitsHeader />', () => {
|
||||
it('shows the amount of visits', () => {
|
||||
const visitsBadge = wrapper.find('.badge');
|
||||
|
||||
expect(visitsBadge.html()).toContain(`Visits: <span><strong>${shortUrlVisits.visits.length}</strong></span>`);
|
||||
expect(visitsBadge.html()).toContain(
|
||||
`Visits: <span><strong class="short-url-visits-count__amount">${shortUrlVisits.visits.length}</strong></span>`
|
||||
);
|
||||
});
|
||||
|
||||
it('shows when the URL was created', () => {
|
||||
|
||||
@@ -72,8 +72,13 @@ describe('shortUrlVisitsReducer', () => {
|
||||
expect(ShlinkApiClient.getShortUrlVisits).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('dispatches start and success when promise is resolved', async () => {
|
||||
it.each([
|
||||
[ undefined, undefined ],
|
||||
[{}, undefined ],
|
||||
[{ domain: 'foobar.com' }, 'foobar.com' ],
|
||||
])('dispatches start and success when promise is resolved', async (query, domain) => {
|
||||
const visits = [{}, {}];
|
||||
const shortCode = 'abc123';
|
||||
const ShlinkApiClient = buildApiClientMock(Promise.resolve({
|
||||
data: visits,
|
||||
pagination: {
|
||||
@@ -82,11 +87,11 @@ describe('shortUrlVisitsReducer', () => {
|
||||
},
|
||||
}));
|
||||
|
||||
await getShortUrlVisits(() => ShlinkApiClient)('abc123')(dispatchMock, getState);
|
||||
await getShortUrlVisits(() => ShlinkApiClient)(shortCode, query)(dispatchMock, getState);
|
||||
|
||||
expect(dispatchMock).toHaveBeenCalledTimes(2);
|
||||
expect(dispatchMock).toHaveBeenNthCalledWith(1, { type: GET_SHORT_URL_VISITS_START });
|
||||
expect(dispatchMock).toHaveBeenNthCalledWith(2, { type: GET_SHORT_URL_VISITS, visits });
|
||||
expect(dispatchMock).toHaveBeenNthCalledWith(2, { type: GET_SHORT_URL_VISITS, visits, shortCode, domain });
|
||||
expect(ShlinkApiClient.getShortUrlVisits).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user