mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 09:30:31 +03:00
Referenced createNewVisits action directly, instead of its action type
This commit is contained in:
parent
22b3794154
commit
692eaf7dc9
17 changed files with 33 additions and 33 deletions
|
@ -1,7 +1,7 @@
|
||||||
import { assoc, assocPath, last, pipe, reject } from 'ramda';
|
import { assoc, assocPath, last, pipe, reject } from 'ramda';
|
||||||
import { Action, Dispatch } from 'redux';
|
import { Action, Dispatch } from 'redux';
|
||||||
import { shortUrlMatches } from '../helpers';
|
import { shortUrlMatches } from '../helpers';
|
||||||
import { CREATE_VISITS, CreateVisitsAction } from '../../visits/reducers/visitCreation';
|
import { createNewVisits, CreateVisitsAction } from '../../visits/reducers/visitCreation';
|
||||||
import { buildReducer } from '../../utils/helpers/redux';
|
import { buildReducer } from '../../utils/helpers/redux';
|
||||||
import { GetState } from '../../container/types';
|
import { GetState } from '../../container/types';
|
||||||
import { ShlinkApiClientBuilder } from '../../api/services/ShlinkApiClientBuilder';
|
import { ShlinkApiClientBuilder } from '../../api/services/ShlinkApiClientBuilder';
|
||||||
|
@ -57,7 +57,7 @@ export default buildReducer<ShortUrlsList, ListShortUrlsCombinedAction>({
|
||||||
state,
|
state,
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
[CREATE_VISITS]: (state, { payload }) => assocPath(
|
[createNewVisits.toString()]: (state, { payload }) => assocPath(
|
||||||
['shortUrls', 'data'],
|
['shortUrls', 'data'],
|
||||||
state.shortUrls?.data?.map(
|
state.shortUrls?.data?.map(
|
||||||
(currentShortUrl) => {
|
(currentShortUrl) => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { isEmpty, reject } from 'ramda';
|
import { isEmpty, reject } from 'ramda';
|
||||||
import { Action, Dispatch } from 'redux';
|
import { Action, Dispatch } from 'redux';
|
||||||
import { CREATE_VISITS, CreateVisitsAction } from '../../visits/reducers/visitCreation';
|
import { createNewVisits, CreateVisitsAction } from '../../visits/reducers/visitCreation';
|
||||||
import { buildReducer } from '../../utils/helpers/redux';
|
import { buildReducer } from '../../utils/helpers/redux';
|
||||||
import { ShlinkTags } from '../../api/types';
|
import { ShlinkTags } from '../../api/types';
|
||||||
import { GetState } from '../../container/types';
|
import { GetState } from '../../container/types';
|
||||||
|
@ -99,7 +99,7 @@ export default buildReducer<TagsList, TagsCombinedAction>({
|
||||||
...state,
|
...state,
|
||||||
filteredTags: state.tags.filter((tag) => tag.toLowerCase().match(searchTerm.toLowerCase())),
|
filteredTags: state.tags.filter((tag) => tag.toLowerCase().match(searchTerm.toLowerCase())),
|
||||||
}),
|
}),
|
||||||
[CREATE_VISITS]: (state, { payload }) => ({
|
[createNewVisits.toString()]: (state, { payload }) => ({
|
||||||
...state,
|
...state,
|
||||||
stats: increaseVisitsForTags(calculateVisitsPerTag(payload.createdVisits), state.stats),
|
stats: increaseVisitsForTags(calculateVisitsPerTag(payload.createdVisits), state.stats),
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { ShlinkVisitsParams } from '../../api/types';
|
||||||
import { ApiErrorAction } from '../../api/types/actions';
|
import { ApiErrorAction } from '../../api/types/actions';
|
||||||
import { isBetween } from '../../utils/helpers/date';
|
import { isBetween } from '../../utils/helpers/date';
|
||||||
import { getVisitsWithLoader, lastVisitLoaderForLoader } from './common';
|
import { getVisitsWithLoader, lastVisitLoaderForLoader } from './common';
|
||||||
import { CREATE_VISITS, CreateVisitsAction } from './visitCreation';
|
import { createNewVisits, CreateVisitsAction } from './visitCreation';
|
||||||
import { domainMatches } from '../../short-urls/helpers';
|
import { domainMatches } from '../../short-urls/helpers';
|
||||||
|
|
||||||
export const GET_DOMAIN_VISITS_START = 'shlink/domainVisits/GET_DOMAIN_VISITS_START';
|
export const GET_DOMAIN_VISITS_START = 'shlink/domainVisits/GET_DOMAIN_VISITS_START';
|
||||||
|
@ -56,7 +56,7 @@ export default buildReducer<DomainVisits, DomainVisitsCombinedAction>({
|
||||||
[GET_DOMAIN_VISITS_CANCEL]: (state) => ({ ...state, cancelLoad: true }),
|
[GET_DOMAIN_VISITS_CANCEL]: (state) => ({ ...state, cancelLoad: true }),
|
||||||
[GET_DOMAIN_VISITS_PROGRESS_CHANGED]: (state, { progress }) => ({ ...state, progress }),
|
[GET_DOMAIN_VISITS_PROGRESS_CHANGED]: (state, { progress }) => ({ ...state, progress }),
|
||||||
[GET_DOMAIN_VISITS_FALLBACK_TO_INTERVAL]: (state, { fallbackInterval }) => ({ ...state, fallbackInterval }),
|
[GET_DOMAIN_VISITS_FALLBACK_TO_INTERVAL]: (state, { fallbackInterval }) => ({ ...state, fallbackInterval }),
|
||||||
[CREATE_VISITS]: (state, { payload }) => {
|
[createNewVisits.toString()]: (state, { payload }) => {
|
||||||
const { domain, visits, query = {} } = state;
|
const { domain, visits, query = {} } = state;
|
||||||
const { startDate, endDate } = query;
|
const { startDate, endDate } = query;
|
||||||
const newVisits = payload.createdVisits
|
const newVisits = payload.createdVisits
|
||||||
|
|
|
@ -12,7 +12,7 @@ import { ShlinkVisitsParams } from '../../api/types';
|
||||||
import { ApiErrorAction } from '../../api/types/actions';
|
import { ApiErrorAction } from '../../api/types/actions';
|
||||||
import { isBetween } from '../../utils/helpers/date';
|
import { isBetween } from '../../utils/helpers/date';
|
||||||
import { getVisitsWithLoader, lastVisitLoaderForLoader } from './common';
|
import { getVisitsWithLoader, lastVisitLoaderForLoader } from './common';
|
||||||
import { CREATE_VISITS, CreateVisitsAction } from './visitCreation';
|
import { createNewVisits, CreateVisitsAction } from './visitCreation';
|
||||||
|
|
||||||
export const GET_NON_ORPHAN_VISITS_START = 'shlink/orphanVisits/GET_NON_ORPHAN_VISITS_START';
|
export const GET_NON_ORPHAN_VISITS_START = 'shlink/orphanVisits/GET_NON_ORPHAN_VISITS_START';
|
||||||
export const GET_NON_ORPHAN_VISITS_ERROR = 'shlink/orphanVisits/GET_NON_ORPHAN_VISITS_ERROR';
|
export const GET_NON_ORPHAN_VISITS_ERROR = 'shlink/orphanVisits/GET_NON_ORPHAN_VISITS_ERROR';
|
||||||
|
@ -52,7 +52,7 @@ export default buildReducer<VisitsInfo, NonOrphanVisitsCombinedAction>({
|
||||||
[GET_NON_ORPHAN_VISITS_CANCEL]: (state) => ({ ...state, cancelLoad: true }),
|
[GET_NON_ORPHAN_VISITS_CANCEL]: (state) => ({ ...state, cancelLoad: true }),
|
||||||
[GET_NON_ORPHAN_VISITS_PROGRESS_CHANGED]: (state, { progress }) => ({ ...state, progress }),
|
[GET_NON_ORPHAN_VISITS_PROGRESS_CHANGED]: (state, { progress }) => ({ ...state, progress }),
|
||||||
[GET_NON_ORPHAN_VISITS_FALLBACK_TO_INTERVAL]: (state, { fallbackInterval }) => ({ ...state, fallbackInterval }),
|
[GET_NON_ORPHAN_VISITS_FALLBACK_TO_INTERVAL]: (state, { fallbackInterval }) => ({ ...state, fallbackInterval }),
|
||||||
[CREATE_VISITS]: (state, { payload }) => {
|
[createNewVisits.toString()]: (state, { payload }) => {
|
||||||
const { visits, query = {} } = state;
|
const { visits, query = {} } = state;
|
||||||
const { startDate, endDate } = query;
|
const { startDate, endDate } = query;
|
||||||
const newVisits = payload.createdVisits
|
const newVisits = payload.createdVisits
|
||||||
|
|
|
@ -15,7 +15,7 @@ import { isOrphanVisit } from '../types/helpers';
|
||||||
import { ApiErrorAction } from '../../api/types/actions';
|
import { ApiErrorAction } from '../../api/types/actions';
|
||||||
import { isBetween } from '../../utils/helpers/date';
|
import { isBetween } from '../../utils/helpers/date';
|
||||||
import { getVisitsWithLoader, lastVisitLoaderForLoader } from './common';
|
import { getVisitsWithLoader, lastVisitLoaderForLoader } from './common';
|
||||||
import { CREATE_VISITS, CreateVisitsAction } from './visitCreation';
|
import { createNewVisits, CreateVisitsAction } from './visitCreation';
|
||||||
|
|
||||||
export const GET_ORPHAN_VISITS_START = 'shlink/orphanVisits/GET_ORPHAN_VISITS_START';
|
export const GET_ORPHAN_VISITS_START = 'shlink/orphanVisits/GET_ORPHAN_VISITS_START';
|
||||||
export const GET_ORPHAN_VISITS_ERROR = 'shlink/orphanVisits/GET_ORPHAN_VISITS_ERROR';
|
export const GET_ORPHAN_VISITS_ERROR = 'shlink/orphanVisits/GET_ORPHAN_VISITS_ERROR';
|
||||||
|
@ -55,7 +55,7 @@ export default buildReducer<VisitsInfo, OrphanVisitsCombinedAction>({
|
||||||
[GET_ORPHAN_VISITS_CANCEL]: (state) => ({ ...state, cancelLoad: true }),
|
[GET_ORPHAN_VISITS_CANCEL]: (state) => ({ ...state, cancelLoad: true }),
|
||||||
[GET_ORPHAN_VISITS_PROGRESS_CHANGED]: (state, { progress }) => ({ ...state, progress }),
|
[GET_ORPHAN_VISITS_PROGRESS_CHANGED]: (state, { progress }) => ({ ...state, progress }),
|
||||||
[GET_ORPHAN_VISITS_FALLBACK_TO_INTERVAL]: (state, { fallbackInterval }) => ({ ...state, fallbackInterval }),
|
[GET_ORPHAN_VISITS_FALLBACK_TO_INTERVAL]: (state, { fallbackInterval }) => ({ ...state, fallbackInterval }),
|
||||||
[CREATE_VISITS]: (state, { payload }) => {
|
[createNewVisits.toString()]: (state, { payload }) => {
|
||||||
const { visits, query = {} } = state;
|
const { visits, query = {} } = state;
|
||||||
const { startDate, endDate } = query;
|
const { startDate, endDate } = query;
|
||||||
const newVisits = payload.createdVisits
|
const newVisits = payload.createdVisits
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { ShlinkVisitsParams } from '../../api/types';
|
||||||
import { ApiErrorAction } from '../../api/types/actions';
|
import { ApiErrorAction } from '../../api/types/actions';
|
||||||
import { isBetween } from '../../utils/helpers/date';
|
import { isBetween } from '../../utils/helpers/date';
|
||||||
import { getVisitsWithLoader, lastVisitLoaderForLoader } from './common';
|
import { getVisitsWithLoader, lastVisitLoaderForLoader } from './common';
|
||||||
import { CREATE_VISITS, CreateVisitsAction } from './visitCreation';
|
import { createNewVisits, CreateVisitsAction } from './visitCreation';
|
||||||
|
|
||||||
export const GET_SHORT_URL_VISITS_START = 'shlink/shortUrlVisits/GET_SHORT_URL_VISITS_START';
|
export const GET_SHORT_URL_VISITS_START = 'shlink/shortUrlVisits/GET_SHORT_URL_VISITS_START';
|
||||||
export const GET_SHORT_URL_VISITS_ERROR = 'shlink/shortUrlVisits/GET_SHORT_URL_VISITS_ERROR';
|
export const GET_SHORT_URL_VISITS_ERROR = 'shlink/shortUrlVisits/GET_SHORT_URL_VISITS_ERROR';
|
||||||
|
@ -60,7 +60,7 @@ export default buildReducer<ShortUrlVisits, ShortUrlVisitsCombinedAction>({
|
||||||
[GET_SHORT_URL_VISITS_CANCEL]: (state) => ({ ...state, cancelLoad: true }),
|
[GET_SHORT_URL_VISITS_CANCEL]: (state) => ({ ...state, cancelLoad: true }),
|
||||||
[GET_SHORT_URL_VISITS_PROGRESS_CHANGED]: (state, { progress }) => ({ ...state, progress }),
|
[GET_SHORT_URL_VISITS_PROGRESS_CHANGED]: (state, { progress }) => ({ ...state, progress }),
|
||||||
[GET_SHORT_URL_VISITS_FALLBACK_TO_INTERVAL]: (state, { fallbackInterval }) => ({ ...state, fallbackInterval }),
|
[GET_SHORT_URL_VISITS_FALLBACK_TO_INTERVAL]: (state, { fallbackInterval }) => ({ ...state, fallbackInterval }),
|
||||||
[CREATE_VISITS]: (state, { payload }) => {
|
[createNewVisits.toString()]: (state, { payload }) => {
|
||||||
const { shortCode, domain, visits, query = {} } = state;
|
const { shortCode, domain, visits, query = {} } = state;
|
||||||
const { startDate, endDate } = query;
|
const { startDate, endDate } = query;
|
||||||
const newVisits = payload.createdVisits
|
const newVisits = payload.createdVisits
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { ShlinkVisitsParams } from '../../api/types';
|
||||||
import { ApiErrorAction } from '../../api/types/actions';
|
import { ApiErrorAction } from '../../api/types/actions';
|
||||||
import { isBetween } from '../../utils/helpers/date';
|
import { isBetween } from '../../utils/helpers/date';
|
||||||
import { getVisitsWithLoader, lastVisitLoaderForLoader } from './common';
|
import { getVisitsWithLoader, lastVisitLoaderForLoader } from './common';
|
||||||
import { CREATE_VISITS, CreateVisitsAction } from './visitCreation';
|
import { createNewVisits, CreateVisitsAction } from './visitCreation';
|
||||||
|
|
||||||
export const GET_TAG_VISITS_START = 'shlink/tagVisits/GET_TAG_VISITS_START';
|
export const GET_TAG_VISITS_START = 'shlink/tagVisits/GET_TAG_VISITS_START';
|
||||||
export const GET_TAG_VISITS_ERROR = 'shlink/tagVisits/GET_TAG_VISITS_ERROR';
|
export const GET_TAG_VISITS_ERROR = 'shlink/tagVisits/GET_TAG_VISITS_ERROR';
|
||||||
|
@ -53,7 +53,7 @@ export default buildReducer<TagVisits, TagsVisitsCombinedAction>({
|
||||||
[GET_TAG_VISITS_CANCEL]: (state) => ({ ...state, cancelLoad: true }),
|
[GET_TAG_VISITS_CANCEL]: (state) => ({ ...state, cancelLoad: true }),
|
||||||
[GET_TAG_VISITS_PROGRESS_CHANGED]: (state, { progress }) => ({ ...state, progress }),
|
[GET_TAG_VISITS_PROGRESS_CHANGED]: (state, { progress }) => ({ ...state, progress }),
|
||||||
[GET_TAG_VISITS_FALLBACK_TO_INTERVAL]: (state, { fallbackInterval }) => ({ ...state, fallbackInterval }),
|
[GET_TAG_VISITS_FALLBACK_TO_INTERVAL]: (state, { fallbackInterval }) => ({ ...state, fallbackInterval }),
|
||||||
[CREATE_VISITS]: (state, { payload }) => {
|
[createNewVisits.toString()]: (state, { payload }) => {
|
||||||
const { tag, visits, query = {} } = state;
|
const { tag, visits, query = {} } = state;
|
||||||
const { startDate, endDate } = query;
|
const { startDate, endDate } = query;
|
||||||
const newVisits = payload.createdVisits
|
const newVisits = payload.createdVisits
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { createAction, PayloadAction } from '@reduxjs/toolkit';
|
import { createAction, PayloadAction } from '@reduxjs/toolkit';
|
||||||
import { CreateVisit } from '../types';
|
import { CreateVisit } from '../types';
|
||||||
|
|
||||||
export const CREATE_VISITS = 'shlink/visitCreation/CREATE_VISITS';
|
const CREATE_VISITS = 'shlink/visitCreation/CREATE_VISITS';
|
||||||
|
|
||||||
export type CreateVisitsAction = PayloadAction<{
|
export type CreateVisitsAction = PayloadAction<{
|
||||||
createdVisits: CreateVisit[];
|
createdVisits: CreateVisit[];
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { ShlinkApiClientBuilder } from '../../api/services/ShlinkApiClientBuilde
|
||||||
import { GetState } from '../../container/types';
|
import { GetState } from '../../container/types';
|
||||||
import { buildReducer } from '../../utils/helpers/redux';
|
import { buildReducer } from '../../utils/helpers/redux';
|
||||||
import { groupNewVisitsByType } from '../types/helpers';
|
import { groupNewVisitsByType } from '../types/helpers';
|
||||||
import { CREATE_VISITS, CreateVisitsAction } from './visitCreation';
|
import { createNewVisits, CreateVisitsAction } from './visitCreation';
|
||||||
|
|
||||||
export const GET_OVERVIEW_START = 'shlink/visitsOverview/GET_OVERVIEW_START';
|
export const GET_OVERVIEW_START = 'shlink/visitsOverview/GET_OVERVIEW_START';
|
||||||
export const GET_OVERVIEW_ERROR = 'shlink/visitsOverview/GET_OVERVIEW_ERROR';
|
export const GET_OVERVIEW_ERROR = 'shlink/visitsOverview/GET_OVERVIEW_ERROR';
|
||||||
|
@ -30,7 +30,7 @@ export default buildReducer<VisitsOverview, GetVisitsOverviewAction & CreateVisi
|
||||||
[GET_OVERVIEW_START]: () => ({ ...initialState, loading: true }),
|
[GET_OVERVIEW_START]: () => ({ ...initialState, loading: true }),
|
||||||
[GET_OVERVIEW_ERROR]: () => ({ ...initialState, error: true }),
|
[GET_OVERVIEW_ERROR]: () => ({ ...initialState, error: true }),
|
||||||
[GET_OVERVIEW]: (_, { visitsCount, orphanVisitsCount }) => ({ ...initialState, visitsCount, orphanVisitsCount }),
|
[GET_OVERVIEW]: (_, { visitsCount, orphanVisitsCount }) => ({ ...initialState, visitsCount, orphanVisitsCount }),
|
||||||
[CREATE_VISITS]: ({ visitsCount, orphanVisitsCount = 0, ...rest }, { payload }) => {
|
[createNewVisits.toString()]: ({ visitsCount, orphanVisitsCount = 0, ...rest }, { payload }) => {
|
||||||
const { regularVisits, orphanVisits } = groupNewVisitsByType(payload.createdVisits);
|
const { regularVisits, orphanVisits } = groupNewVisitsByType(payload.createdVisits);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -6,12 +6,12 @@ import reducer, {
|
||||||
listShortUrls,
|
listShortUrls,
|
||||||
} from '../../../src/short-urls/reducers/shortUrlsList';
|
} from '../../../src/short-urls/reducers/shortUrlsList';
|
||||||
import { SHORT_URL_DELETED } from '../../../src/short-urls/reducers/shortUrlDeletion';
|
import { SHORT_URL_DELETED } from '../../../src/short-urls/reducers/shortUrlDeletion';
|
||||||
import { CREATE_VISITS } from '../../../src/visits/reducers/visitCreation';
|
|
||||||
import { ShortUrl } from '../../../src/short-urls/data';
|
import { ShortUrl } from '../../../src/short-urls/data';
|
||||||
import { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
|
import { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
|
||||||
import { ShlinkPaginator, ShlinkShortUrlsResponse } from '../../../src/api/types';
|
import { ShlinkPaginator, ShlinkShortUrlsResponse } from '../../../src/api/types';
|
||||||
import { CREATE_SHORT_URL } from '../../../src/short-urls/reducers/shortUrlCreation';
|
import { CREATE_SHORT_URL } from '../../../src/short-urls/reducers/shortUrlCreation';
|
||||||
import { SHORT_URL_EDITED } from '../../../src/short-urls/reducers/shortUrlEdition';
|
import { SHORT_URL_EDITED } from '../../../src/short-urls/reducers/shortUrlEdition';
|
||||||
|
import { createNewVisits } from '../../../src/visits/reducers/visitCreation';
|
||||||
|
|
||||||
describe('shortUrlsListReducer', () => {
|
describe('shortUrlsListReducer', () => {
|
||||||
const shortCode = 'abc123';
|
const shortCode = 'abc123';
|
||||||
|
@ -85,7 +85,7 @@ describe('shortUrlsListReducer', () => {
|
||||||
error: false,
|
error: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(reducer(state, { type: CREATE_VISITS, payload: { createdVisits } } as any)).toEqual({
|
expect(reducer(state, { type: createNewVisits.toString(), payload: { createdVisits } } as any)).toEqual({
|
||||||
shortUrls: {
|
shortUrls: {
|
||||||
data: [
|
data: [
|
||||||
{ shortCode, domain: 'example.com', visitsCount: 5 },
|
{ shortCode, domain: 'example.com', visitsCount: 5 },
|
||||||
|
|
|
@ -13,7 +13,6 @@ import reducer, {
|
||||||
DomainVisits,
|
DomainVisits,
|
||||||
DEFAULT_DOMAIN,
|
DEFAULT_DOMAIN,
|
||||||
} from '../../../src/visits/reducers/domainVisits';
|
} from '../../../src/visits/reducers/domainVisits';
|
||||||
import { CREATE_VISITS } from '../../../src/visits/reducers/visitCreation';
|
|
||||||
import { rangeOf } from '../../../src/utils/utils';
|
import { rangeOf } from '../../../src/utils/utils';
|
||||||
import { Visit } from '../../../src/visits/types';
|
import { Visit } from '../../../src/visits/types';
|
||||||
import { ShlinkVisits } from '../../../src/api/types';
|
import { ShlinkVisits } from '../../../src/api/types';
|
||||||
|
@ -22,6 +21,7 @@ import { ShlinkState } from '../../../src/container/types';
|
||||||
import { formatIsoDate } from '../../../src/utils/helpers/date';
|
import { formatIsoDate } from '../../../src/utils/helpers/date';
|
||||||
import { DateInterval } from '../../../src/utils/dates/types';
|
import { DateInterval } from '../../../src/utils/dates/types';
|
||||||
import { ShortUrl } from '../../../src/short-urls/data';
|
import { ShortUrl } from '../../../src/short-urls/data';
|
||||||
|
import { createNewVisits } from '../../../src/visits/reducers/visitCreation';
|
||||||
|
|
||||||
describe('domainVisitsReducer', () => {
|
describe('domainVisitsReducer', () => {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
@ -134,7 +134,7 @@ describe('domainVisitsReducer', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const { visits } = reducer(prevState, {
|
const { visits } = reducer(prevState, {
|
||||||
type: CREATE_VISITS,
|
type: createNewVisits.toString(),
|
||||||
payload: { createdVisits: [{ shortUrl, visit: { date: formatIsoDate(now) ?? undefined } }] },
|
payload: { createdVisits: [{ shortUrl, visit: { date: formatIsoDate(now) ?? undefined } }] },
|
||||||
} as any);
|
} as any);
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ import reducer, {
|
||||||
GET_NON_ORPHAN_VISITS_PROGRESS_CHANGED,
|
GET_NON_ORPHAN_VISITS_PROGRESS_CHANGED,
|
||||||
GET_NON_ORPHAN_VISITS_FALLBACK_TO_INTERVAL,
|
GET_NON_ORPHAN_VISITS_FALLBACK_TO_INTERVAL,
|
||||||
} from '../../../src/visits/reducers/nonOrphanVisits';
|
} from '../../../src/visits/reducers/nonOrphanVisits';
|
||||||
import { CREATE_VISITS } from '../../../src/visits/reducers/visitCreation';
|
|
||||||
import { rangeOf } from '../../../src/utils/utils';
|
import { rangeOf } from '../../../src/utils/utils';
|
||||||
import { Visit, VisitsInfo } from '../../../src/visits/types';
|
import { Visit, VisitsInfo } from '../../../src/visits/types';
|
||||||
import { ShlinkVisits } from '../../../src/api/types';
|
import { ShlinkVisits } from '../../../src/api/types';
|
||||||
|
@ -19,6 +18,7 @@ import { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
|
||||||
import { ShlinkState } from '../../../src/container/types';
|
import { ShlinkState } from '../../../src/container/types';
|
||||||
import { formatIsoDate } from '../../../src/utils/helpers/date';
|
import { formatIsoDate } from '../../../src/utils/helpers/date';
|
||||||
import { DateInterval } from '../../../src/utils/dates/types';
|
import { DateInterval } from '../../../src/utils/dates/types';
|
||||||
|
import { createNewVisits } from '../../../src/visits/reducers/visitCreation';
|
||||||
|
|
||||||
describe('nonOrphanVisitsReducer', () => {
|
describe('nonOrphanVisitsReducer', () => {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
@ -106,7 +106,7 @@ describe('nonOrphanVisitsReducer', () => {
|
||||||
const visit = Mock.of<Visit>({ date: formatIsoDate(now) ?? undefined });
|
const visit = Mock.of<Visit>({ date: formatIsoDate(now) ?? undefined });
|
||||||
|
|
||||||
const { visits } = reducer(prevState, {
|
const { visits } = reducer(prevState, {
|
||||||
type: CREATE_VISITS,
|
type: createNewVisits.toString(),
|
||||||
payload: { createdVisits: [{ visit }, { visit }] },
|
payload: { createdVisits: [{ visit }, { visit }] },
|
||||||
} as any);
|
} as any);
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ import reducer, {
|
||||||
GET_ORPHAN_VISITS_PROGRESS_CHANGED,
|
GET_ORPHAN_VISITS_PROGRESS_CHANGED,
|
||||||
GET_ORPHAN_VISITS_FALLBACK_TO_INTERVAL,
|
GET_ORPHAN_VISITS_FALLBACK_TO_INTERVAL,
|
||||||
} from '../../../src/visits/reducers/orphanVisits';
|
} from '../../../src/visits/reducers/orphanVisits';
|
||||||
import { CREATE_VISITS } from '../../../src/visits/reducers/visitCreation';
|
|
||||||
import { rangeOf } from '../../../src/utils/utils';
|
import { rangeOf } from '../../../src/utils/utils';
|
||||||
import { Visit, VisitsInfo } from '../../../src/visits/types';
|
import { Visit, VisitsInfo } from '../../../src/visits/types';
|
||||||
import { ShlinkVisits } from '../../../src/api/types';
|
import { ShlinkVisits } from '../../../src/api/types';
|
||||||
|
@ -19,6 +18,7 @@ import { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
|
||||||
import { ShlinkState } from '../../../src/container/types';
|
import { ShlinkState } from '../../../src/container/types';
|
||||||
import { formatIsoDate } from '../../../src/utils/helpers/date';
|
import { formatIsoDate } from '../../../src/utils/helpers/date';
|
||||||
import { DateInterval } from '../../../src/utils/dates/types';
|
import { DateInterval } from '../../../src/utils/dates/types';
|
||||||
|
import { createNewVisits } from '../../../src/visits/reducers/visitCreation';
|
||||||
|
|
||||||
describe('orphanVisitsReducer', () => {
|
describe('orphanVisitsReducer', () => {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
@ -106,7 +106,7 @@ describe('orphanVisitsReducer', () => {
|
||||||
const visit = Mock.of<Visit>({ date: formatIsoDate(now) ?? undefined });
|
const visit = Mock.of<Visit>({ date: formatIsoDate(now) ?? undefined });
|
||||||
|
|
||||||
const { visits } = reducer(prevState, {
|
const { visits } = reducer(prevState, {
|
||||||
type: CREATE_VISITS,
|
type: createNewVisits.toString(),
|
||||||
payload: { createdVisits: [{ visit }, { visit }] },
|
payload: { createdVisits: [{ visit }, { visit }] },
|
||||||
} as any);
|
} as any);
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ import reducer, {
|
||||||
GET_SHORT_URL_VISITS_FALLBACK_TO_INTERVAL,
|
GET_SHORT_URL_VISITS_FALLBACK_TO_INTERVAL,
|
||||||
ShortUrlVisits,
|
ShortUrlVisits,
|
||||||
} from '../../../src/visits/reducers/shortUrlVisits';
|
} from '../../../src/visits/reducers/shortUrlVisits';
|
||||||
import { CREATE_VISITS } from '../../../src/visits/reducers/visitCreation';
|
|
||||||
import { rangeOf } from '../../../src/utils/utils';
|
import { rangeOf } from '../../../src/utils/utils';
|
||||||
import { Visit } from '../../../src/visits/types';
|
import { Visit } from '../../../src/visits/types';
|
||||||
import { ShlinkVisits } from '../../../src/api/types';
|
import { ShlinkVisits } from '../../../src/api/types';
|
||||||
|
@ -20,6 +19,7 @@ import { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
|
||||||
import { ShlinkState } from '../../../src/container/types';
|
import { ShlinkState } from '../../../src/container/types';
|
||||||
import { formatIsoDate } from '../../../src/utils/helpers/date';
|
import { formatIsoDate } from '../../../src/utils/helpers/date';
|
||||||
import { DateInterval } from '../../../src/utils/dates/types';
|
import { DateInterval } from '../../../src/utils/dates/types';
|
||||||
|
import { createNewVisits } from '../../../src/visits/reducers/visitCreation';
|
||||||
|
|
||||||
describe('shortUrlVisitsReducer', () => {
|
describe('shortUrlVisitsReducer', () => {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
@ -127,7 +127,7 @@ describe('shortUrlVisitsReducer', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const { visits } = reducer(prevState, {
|
const { visits } = reducer(prevState, {
|
||||||
type: CREATE_VISITS,
|
type: createNewVisits.toString(),
|
||||||
payload: { createdVisits: [{ shortUrl, visit: { date: formatIsoDate(now) ?? undefined } }] },
|
payload: { createdVisits: [{ shortUrl, visit: { date: formatIsoDate(now) ?? undefined } }] },
|
||||||
} as any);
|
} as any);
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ import reducer, {
|
||||||
GET_TAG_VISITS_FALLBACK_TO_INTERVAL,
|
GET_TAG_VISITS_FALLBACK_TO_INTERVAL,
|
||||||
TagVisits,
|
TagVisits,
|
||||||
} from '../../../src/visits/reducers/tagVisits';
|
} from '../../../src/visits/reducers/tagVisits';
|
||||||
import { CREATE_VISITS } from '../../../src/visits/reducers/visitCreation';
|
|
||||||
import { rangeOf } from '../../../src/utils/utils';
|
import { rangeOf } from '../../../src/utils/utils';
|
||||||
import { Visit } from '../../../src/visits/types';
|
import { Visit } from '../../../src/visits/types';
|
||||||
import { ShlinkVisits } from '../../../src/api/types';
|
import { ShlinkVisits } from '../../../src/api/types';
|
||||||
|
@ -20,6 +19,7 @@ import { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
|
||||||
import { ShlinkState } from '../../../src/container/types';
|
import { ShlinkState } from '../../../src/container/types';
|
||||||
import { formatIsoDate } from '../../../src/utils/helpers/date';
|
import { formatIsoDate } from '../../../src/utils/helpers/date';
|
||||||
import { DateInterval } from '../../../src/utils/dates/types';
|
import { DateInterval } from '../../../src/utils/dates/types';
|
||||||
|
import { createNewVisits } from '../../../src/visits/reducers/visitCreation';
|
||||||
|
|
||||||
describe('tagVisitsReducer', () => {
|
describe('tagVisitsReducer', () => {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
@ -127,7 +127,7 @@ describe('tagVisitsReducer', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const { visits } = reducer(prevState, {
|
const { visits } = reducer(prevState, {
|
||||||
type: CREATE_VISITS,
|
type: createNewVisits.toString(),
|
||||||
payload: { createdVisits: [{ shortUrl, visit: { date: formatIsoDate(now) ?? undefined } }] },
|
payload: { createdVisits: [{ shortUrl, visit: { date: formatIsoDate(now) ?? undefined } }] },
|
||||||
} as any);
|
} as any);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Mock } from 'ts-mockery';
|
import { Mock } from 'ts-mockery';
|
||||||
import { CREATE_VISITS, createNewVisits } from '../../../src/visits/reducers/visitCreation';
|
import { createNewVisits } from '../../../src/visits/reducers/visitCreation';
|
||||||
import { ShortUrl } from '../../../src/short-urls/data';
|
import { ShortUrl } from '../../../src/short-urls/data';
|
||||||
import { Visit } from '../../../src/visits/types';
|
import { Visit } from '../../../src/visits/types';
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ describe('visitCreationReducer', () => {
|
||||||
|
|
||||||
it('just returns the action with proper type', () => {
|
it('just returns the action with proper type', () => {
|
||||||
expect(createNewVisits([{ shortUrl, visit }])).toEqual({
|
expect(createNewVisits([{ shortUrl, visit }])).toEqual({
|
||||||
type: CREATE_VISITS,
|
type: createNewVisits.toString(),
|
||||||
payload: { createdVisits: [{ shortUrl, visit }] },
|
payload: { createdVisits: [{ shortUrl, visit }] },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,7 +7,7 @@ import reducer, {
|
||||||
VisitsOverview,
|
VisitsOverview,
|
||||||
loadVisitsOverview,
|
loadVisitsOverview,
|
||||||
} from '../../../src/visits/reducers/visitsOverview';
|
} from '../../../src/visits/reducers/visitsOverview';
|
||||||
import { CREATE_VISITS, CreateVisitsAction } from '../../../src/visits/reducers/visitCreation';
|
import { createNewVisits, CreateVisitsAction } from '../../../src/visits/reducers/visitCreation';
|
||||||
import { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
|
import { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
|
||||||
import { ShlinkVisitsOverview } from '../../../src/api/types';
|
import { ShlinkVisitsOverview } from '../../../src/api/types';
|
||||||
import { ShlinkState } from '../../../src/container/types';
|
import { ShlinkState } from '../../../src/container/types';
|
||||||
|
@ -51,7 +51,7 @@ describe('visitsOverviewReducer', () => {
|
||||||
const { visitsCount, orphanVisitsCount } = reducer(
|
const { visitsCount, orphanVisitsCount } = reducer(
|
||||||
state({ visitsCount: 100, orphanVisitsCount: providedOrphanVisitsCount }),
|
state({ visitsCount: 100, orphanVisitsCount: providedOrphanVisitsCount }),
|
||||||
{
|
{
|
||||||
type: CREATE_VISITS,
|
type: createNewVisits.toString(),
|
||||||
payload: {
|
payload: {
|
||||||
createdVisits: [
|
createdVisits: [
|
||||||
Mock.of<CreateVisit>({ visit: Mock.all<Visit>() }),
|
Mock.of<CreateVisit>({ visit: Mock.all<Visit>() }),
|
||||||
|
|
Loading…
Reference in a new issue