Added progress bar to visits page when loading a lot of visits

This commit is contained in:
Alejandro Celaya
2020-05-11 19:32:42 +02:00
parent 9bdbe90716
commit 07d3567244
9 changed files with 59 additions and 14 deletions

View File

@@ -6,6 +6,7 @@ import reducer, {
GET_SHORT_URL_VISITS,
GET_SHORT_URL_VISITS_LARGE,
GET_SHORT_URL_VISITS_CANCEL,
GET_SHORT_URL_VISITS_PROGRESS_CHANGED,
} from '../../../src/visits/reducers/shortUrlVisits';
import { CREATE_VISIT } from '../../../src/visits/reducers/visitCreation';
@@ -66,6 +67,12 @@ describe('shortUrlVisitsReducer', () => {
expect(visits).toEqual(expectedVisits);
});
it('returns new progress on GET_SHORT_URL_VISITS_PROGRESS_CHANGED', () => {
const state = reducer({}, { type: GET_SHORT_URL_VISITS_PROGRESS_CHANGED, progress: 85 });
expect(state).toEqual({ progress: 85 });
});
});
describe('getShortUrlVisits', () => {
@@ -127,7 +134,7 @@ describe('shortUrlVisitsReducer', () => {
await getShortUrlVisits(() => ShlinkApiClient)('abc123')(dispatchMock, getState);
expect(ShlinkApiClient.getShortUrlVisits).toHaveBeenCalledTimes(expectedRequests);
expect(dispatchMock).toHaveBeenNthCalledWith(2, expect.objectContaining({
expect(dispatchMock).toHaveBeenNthCalledWith(3, expect.objectContaining({
visits: [{}, {}, {}, {}, {}, {}],
}));
});

View File

@@ -6,6 +6,7 @@ import reducer, {
GET_TAG_VISITS,
GET_TAG_VISITS_LARGE,
GET_TAG_VISITS_CANCEL,
GET_TAG_VISITS_PROGRESS_CHANGED,
} from '../../../src/visits/reducers/tagVisits';
import { CREATE_VISIT } from '../../../src/visits/reducers/visitCreation';
@@ -66,6 +67,12 @@ describe('tagVisitsReducer', () => {
expect(visits).toEqual(expectedVisits);
});
it('returns new progress on GET_TAG_VISITS_PROGRESS_CHANGED', () => {
const state = reducer({}, { type: GET_TAG_VISITS_PROGRESS_CHANGED, progress: 85 });
expect(state).toEqual({ progress: 85 });
});
});
describe('getTagVisits', () => {