mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-13 11:03:50 +00:00
Added more tests covering new use cases
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
import reducer, {
|
||||
getShortUrlVisits,
|
||||
cancelGetShortUrlVisits,
|
||||
createNewVisit,
|
||||
GET_SHORT_URL_VISITS_START,
|
||||
GET_SHORT_URL_VISITS_ERROR,
|
||||
GET_SHORT_URL_VISITS,
|
||||
GET_SHORT_URL_VISITS_LARGE,
|
||||
GET_SHORT_URL_VISITS_CANCEL,
|
||||
CREATE_SHORT_URL_VISIT,
|
||||
} from '../../../src/visits/reducers/shortUrlVisits';
|
||||
|
||||
describe('shortUrlVisitsReducer', () => {
|
||||
@@ -48,6 +50,23 @@ describe('shortUrlVisitsReducer', () => {
|
||||
expect(error).toEqual(false);
|
||||
expect(visits).toEqual(actionVisits);
|
||||
});
|
||||
|
||||
it.each([
|
||||
[{ shortCode: 'abc123' }, [{}, {}, {}]],
|
||||
[{ shortCode: 'def456' }, [{}, {}]],
|
||||
])('appends a new visit on CREATE_SHORT_URL_VISIT', (state, expectedVisits) => {
|
||||
const shortUrl = {
|
||||
shortCode: 'abc123',
|
||||
};
|
||||
const prevState = {
|
||||
...state,
|
||||
visits: [{}, {}],
|
||||
};
|
||||
|
||||
const { visits } = reducer(prevState, { type: CREATE_SHORT_URL_VISIT, shortUrl, visit: {} });
|
||||
|
||||
expect(visits).toEqual(expectedVisits);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getShortUrlVisits', () => {
|
||||
@@ -119,4 +138,11 @@ describe('shortUrlVisitsReducer', () => {
|
||||
it('just returns the action with proper type', () =>
|
||||
expect(cancelGetShortUrlVisits()).toEqual({ type: GET_SHORT_URL_VISITS_CANCEL }));
|
||||
});
|
||||
|
||||
describe('createNewVisit', () => {
|
||||
it('just returns the action with proper type', () =>
|
||||
expect(createNewVisit({ shortUrl: {}, visit: {} })).toEqual(
|
||||
{ type: CREATE_SHORT_URL_VISIT, shortUrl: {}, visit: {} }
|
||||
));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user