mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-11 01:53:51 +00:00
Ensured visits loading is cancelled when the visits page is unmounted
This commit is contained in:
@@ -29,6 +29,7 @@ describe('<ShortUrlVisits />', () => {
|
||||
match={match}
|
||||
shortUrlVisits={shortUrlVisits}
|
||||
shortUrlDetail={{}}
|
||||
cancelGetShortUrlVisits={identity}
|
||||
/>
|
||||
);
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import reducer, {
|
||||
GET_SHORT_URL_VISITS_ERROR,
|
||||
GET_SHORT_URL_VISITS,
|
||||
GET_SHORT_URL_VISITS_LARGE,
|
||||
GET_SHORT_URL_VISITS_CANCEL,
|
||||
} from '../../../src/visits/reducers/shortUrlVisits';
|
||||
|
||||
describe('shortUrlVisitsReducer', () => {
|
||||
@@ -23,6 +24,13 @@ describe('shortUrlVisitsReducer', () => {
|
||||
expect(loadingLarge).toEqual(true);
|
||||
});
|
||||
|
||||
it('returns cancelLoad on GET_SHORT_URL_VISITS_CANCEL', () => {
|
||||
const state = reducer({ cancelLoad: false }, { type: GET_SHORT_URL_VISITS_CANCEL });
|
||||
const { cancelLoad } = state;
|
||||
|
||||
expect(cancelLoad).toEqual(true);
|
||||
});
|
||||
|
||||
it('stops loading and returns error on GET_SHORT_URL_VISITS_ERROR', () => {
|
||||
const state = reducer({ loading: true, error: false }, { type: GET_SHORT_URL_VISITS_ERROR });
|
||||
const { loading, error } = state;
|
||||
@@ -58,7 +66,9 @@ describe('shortUrlVisitsReducer', () => {
|
||||
getShortUrlVisits: typeof returned === 'function' ? sinon.fake(returned) : sinon.fake.returns(returned),
|
||||
});
|
||||
const dispatchMock = sinon.spy();
|
||||
const getState = () => ({});
|
||||
const getState = () => ({
|
||||
shortUrlVisits: { cancelVisits: false },
|
||||
});
|
||||
|
||||
beforeEach(() => dispatchMock.resetHistory());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user