mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 01:20:24 +03:00
Finish replacing ts-mockery with shoehorn
This commit is contained in:
parent
04e1950591
commit
26bad75a1a
12 changed files with 131 additions and 166 deletions
17
package-lock.json
generated
17
package-lock.json
generated
|
@ -85,7 +85,6 @@
|
||||||
"resize-observer-polyfill": "^1.5.1",
|
"resize-observer-polyfill": "^1.5.1",
|
||||||
"sass": "^1.57.1",
|
"sass": "^1.57.1",
|
||||||
"stylelint": "^14.16.0",
|
"stylelint": "^14.16.0",
|
||||||
"ts-mockery": "^1.2.0",
|
|
||||||
"typescript": "^5.0.2",
|
"typescript": "^5.0.2",
|
||||||
"vite": "^4.2.0",
|
"vite": "^4.2.0",
|
||||||
"vite-plugin-pwa": "^0.14.4"
|
"vite-plugin-pwa": "^0.14.4"
|
||||||
|
@ -11902,14 +11901,6 @@
|
||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ts-mockery": {
|
|
||||||
"version": "1.2.0",
|
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
|
||||||
"peerDependencies": {
|
|
||||||
"typescript": ">= 2.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/ts-toolbelt": {
|
"node_modules/ts-toolbelt": {
|
||||||
"version": "6.15.5",
|
"version": "6.15.5",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
@ -15897,6 +15888,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"caniuse-lite": {
|
||||||
|
"version": "1.0.30001415"
|
||||||
|
},
|
||||||
"chalk": {
|
"chalk": {
|
||||||
"version": "5.2.0",
|
"version": "5.2.0",
|
||||||
"dev": true
|
"dev": true
|
||||||
|
@ -20285,11 +20279,6 @@
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"ts-mockery": {
|
|
||||||
"version": "1.2.0",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {}
|
|
||||||
},
|
|
||||||
"ts-toolbelt": {
|
"ts-toolbelt": {
|
||||||
"version": "6.15.5",
|
"version": "6.15.5",
|
||||||
"dev": true
|
"dev": true
|
||||||
|
|
|
@ -102,7 +102,6 @@
|
||||||
"resize-observer-polyfill": "^1.5.1",
|
"resize-observer-polyfill": "^1.5.1",
|
||||||
"sass": "^1.57.1",
|
"sass": "^1.57.1",
|
||||||
"stylelint": "^14.16.0",
|
"stylelint": "^14.16.0",
|
||||||
"ts-mockery": "^1.2.0",
|
|
||||||
"typescript": "^5.0.2",
|
"typescript": "^5.0.2",
|
||||||
"vite": "^4.2.0",
|
"vite": "^4.2.0",
|
||||||
"vite-plugin-pwa": "^0.14.4"
|
"vite-plugin-pwa": "^0.14.4"
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import { screen, waitFor } from '@testing-library/react';
|
import { screen, waitFor } from '@testing-library/react';
|
||||||
import { Mock } from 'ts-mockery';
|
import { fromPartial } from '@total-typescript/shoehorn';
|
||||||
import { OpenMapModalBtn } from '../../../src/visits/helpers/OpenMapModalBtn';
|
import { OpenMapModalBtn } from '../../../src/visits/helpers/OpenMapModalBtn';
|
||||||
import type { CityStats } from '../../../src/visits/types';
|
import type { CityStats } from '../../../src/visits/types';
|
||||||
import { renderWithEvents } from '../../__helpers__/setUpTest';
|
import { renderWithEvents } from '../../__helpers__/setUpTest';
|
||||||
|
|
||||||
describe('<OpenMapModalBtn />', () => {
|
describe('<OpenMapModalBtn />', () => {
|
||||||
const title = 'Foo';
|
const title = 'Foo';
|
||||||
const locations = [
|
const locations: CityStats[] = [
|
||||||
Mock.of<CityStats>({ cityName: 'foo', count: 30, latLong: [5, 5] }),
|
fromPartial({ cityName: 'foo', count: 30, latLong: [5, 5] }),
|
||||||
Mock.of<CityStats>({ cityName: 'bar', count: 45, latLong: [88, 88] }),
|
fromPartial({ cityName: 'bar', count: 45, latLong: [88, 88] }),
|
||||||
];
|
];
|
||||||
const setUp = (activeCities?: string[]) => renderWithEvents(
|
const setUp = (activeCities?: string[]) => renderWithEvents(
|
||||||
<OpenMapModalBtn modalTitle={title} locations={locations} activeCities={activeCities} />,
|
<OpenMapModalBtn modalTitle={title} locations={locations} activeCities={activeCities} />,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
import { fromPartial } from '@total-typescript/shoehorn';
|
||||||
import { addDays, formatISO, subDays } from 'date-fns';
|
import { addDays, formatISO, subDays } from 'date-fns';
|
||||||
import { Mock } from 'ts-mockery';
|
|
||||||
import type { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
|
import type { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
|
||||||
import type { ShlinkVisits } from '../../../src/api/types';
|
import type { ShlinkVisits } from '../../../src/api/types';
|
||||||
import type { ShlinkState } from '../../../src/container/types';
|
import type { ShlinkState } from '../../../src/container/types';
|
||||||
|
@ -16,25 +16,25 @@ import {
|
||||||
getDomainVisits as getDomainVisitsCreator,
|
getDomainVisits as getDomainVisitsCreator,
|
||||||
} from '../../../src/visits/reducers/domainVisits';
|
} from '../../../src/visits/reducers/domainVisits';
|
||||||
import { createNewVisits } from '../../../src/visits/reducers/visitCreation';
|
import { createNewVisits } from '../../../src/visits/reducers/visitCreation';
|
||||||
import type { CreateVisit, Visit } from '../../../src/visits/types';
|
import type { Visit } from '../../../src/visits/types';
|
||||||
|
|
||||||
describe('domainVisitsReducer', () => {
|
describe('domainVisitsReducer', () => {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const visitsMocks = rangeOf(2, () => Mock.all<Visit>());
|
const visitsMocks = rangeOf(2, () => fromPartial<Visit>({}));
|
||||||
const getDomainVisitsCall = jest.fn();
|
const getDomainVisitsCall = jest.fn();
|
||||||
const buildApiClientMock = () => Mock.of<ShlinkApiClient>({ getDomainVisits: getDomainVisitsCall });
|
const buildApiClientMock = () => fromPartial<ShlinkApiClient>({ getDomainVisits: getDomainVisitsCall });
|
||||||
const getDomainVisits = getDomainVisitsCreator(buildApiClientMock);
|
const getDomainVisits = getDomainVisitsCreator(buildApiClientMock);
|
||||||
const { reducer, cancelGetVisits: cancelGetDomainVisits } = domainVisitsReducerCreator(getDomainVisits);
|
const { reducer, cancelGetVisits: cancelGetDomainVisits } = domainVisitsReducerCreator(getDomainVisits);
|
||||||
|
|
||||||
beforeEach(jest.clearAllMocks);
|
beforeEach(jest.clearAllMocks);
|
||||||
|
|
||||||
describe('reducer', () => {
|
describe('reducer', () => {
|
||||||
const buildState = (data: Partial<DomainVisits>) => Mock.of<DomainVisits>(data);
|
const buildState = (data: Partial<DomainVisits>) => fromPartial<DomainVisits>(data);
|
||||||
|
|
||||||
it('returns loading on GET_DOMAIN_VISITS_START', () => {
|
it('returns loading on GET_DOMAIN_VISITS_START', () => {
|
||||||
const { loading } = reducer(
|
const { loading } = reducer(
|
||||||
buildState({ loading: false }),
|
buildState({ loading: false }),
|
||||||
getDomainVisits.pending('', Mock.all<LoadDomainVisits>()),
|
getDomainVisits.pending('', fromPartial<LoadDomainVisits>({})),
|
||||||
);
|
);
|
||||||
expect(loading).toEqual(true);
|
expect(loading).toEqual(true);
|
||||||
});
|
});
|
||||||
|
@ -52,7 +52,7 @@ describe('domainVisitsReducer', () => {
|
||||||
it('stops loading and returns error on GET_DOMAIN_VISITS_ERROR', () => {
|
it('stops loading and returns error on GET_DOMAIN_VISITS_ERROR', () => {
|
||||||
const state = reducer(
|
const state = reducer(
|
||||||
buildState({ loading: true, error: false }),
|
buildState({ loading: true, error: false }),
|
||||||
getDomainVisits.rejected(null, '', Mock.all<LoadDomainVisits>()),
|
getDomainVisits.rejected(null, '', fromPartial({})),
|
||||||
);
|
);
|
||||||
const { loading, error } = state;
|
const { loading, error } = state;
|
||||||
|
|
||||||
|
@ -61,10 +61,10 @@ describe('domainVisitsReducer', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('return visits on GET_DOMAIN_VISITS', () => {
|
it('return visits on GET_DOMAIN_VISITS', () => {
|
||||||
const actionVisits = [Mock.all<Visit>(), Mock.all<Visit>()];
|
const actionVisits: Visit[] = [fromPartial({}), fromPartial({})];
|
||||||
const { loading, error, visits } = reducer(
|
const { loading, error, visits } = reducer(
|
||||||
buildState({ loading: true, error: false }),
|
buildState({ loading: true, error: false }),
|
||||||
getDomainVisits.fulfilled({ visits: actionVisits }, '', Mock.all<LoadDomainVisits>()),
|
getDomainVisits.fulfilled({ visits: actionVisits }, '', fromPartial({})),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(loading).toEqual(false);
|
expect(loading).toEqual(false);
|
||||||
|
@ -75,10 +75,10 @@ describe('domainVisitsReducer', () => {
|
||||||
it.each([
|
it.each([
|
||||||
[{ domain: 'foo.com' }, 'foo.com', visitsMocks.length + 1],
|
[{ domain: 'foo.com' }, 'foo.com', visitsMocks.length + 1],
|
||||||
[{ domain: 'bar.com' }, 'foo.com', visitsMocks.length],
|
[{ domain: 'bar.com' }, 'foo.com', visitsMocks.length],
|
||||||
[Mock.of<DomainVisits>({ domain: 'foo.com' }), 'foo.com', visitsMocks.length + 1],
|
[fromPartial<DomainVisits>({ domain: 'foo.com' }), 'foo.com', visitsMocks.length + 1],
|
||||||
[Mock.of<DomainVisits>({ domain: DEFAULT_DOMAIN }), null, visitsMocks.length + 1],
|
[fromPartial<DomainVisits>({ domain: DEFAULT_DOMAIN }), null, visitsMocks.length + 1],
|
||||||
[
|
[
|
||||||
Mock.of<DomainVisits>({
|
fromPartial<DomainVisits>({
|
||||||
domain: 'foo.com',
|
domain: 'foo.com',
|
||||||
query: { endDate: formatIsoDate(subDays(now, 1)) ?? undefined },
|
query: { endDate: formatIsoDate(subDays(now, 1)) ?? undefined },
|
||||||
}),
|
}),
|
||||||
|
@ -86,7 +86,7 @@ describe('domainVisitsReducer', () => {
|
||||||
visitsMocks.length,
|
visitsMocks.length,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
Mock.of<DomainVisits>({
|
fromPartial<DomainVisits>({
|
||||||
domain: 'foo.com',
|
domain: 'foo.com',
|
||||||
query: { startDate: formatIsoDate(addDays(now, 1)) ?? undefined },
|
query: { startDate: formatIsoDate(addDays(now, 1)) ?? undefined },
|
||||||
}),
|
}),
|
||||||
|
@ -94,7 +94,7 @@ describe('domainVisitsReducer', () => {
|
||||||
visitsMocks.length,
|
visitsMocks.length,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
Mock.of<DomainVisits>({
|
fromPartial<DomainVisits>({
|
||||||
domain: 'foo.com',
|
domain: 'foo.com',
|
||||||
query: {
|
query: {
|
||||||
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
||||||
|
@ -105,7 +105,7 @@ describe('domainVisitsReducer', () => {
|
||||||
visitsMocks.length,
|
visitsMocks.length,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
Mock.of<DomainVisits>({
|
fromPartial<DomainVisits>({
|
||||||
domain: 'foo.com',
|
domain: 'foo.com',
|
||||||
query: {
|
query: {
|
||||||
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
||||||
|
@ -116,7 +116,7 @@ describe('domainVisitsReducer', () => {
|
||||||
visitsMocks.length + 1,
|
visitsMocks.length + 1,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
Mock.of<DomainVisits>({
|
fromPartial<DomainVisits>({
|
||||||
domain: 'bar.com',
|
domain: 'bar.com',
|
||||||
query: {
|
query: {
|
||||||
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
||||||
|
@ -127,9 +127,9 @@ describe('domainVisitsReducer', () => {
|
||||||
visitsMocks.length,
|
visitsMocks.length,
|
||||||
],
|
],
|
||||||
])('prepends new visits on CREATE_VISIT', (state, shortUrlDomain, expectedVisits) => {
|
])('prepends new visits on CREATE_VISIT', (state, shortUrlDomain, expectedVisits) => {
|
||||||
const shortUrl = Mock.of<ShortUrl>({ domain: shortUrlDomain });
|
const shortUrl = fromPartial<ShortUrl>({ domain: shortUrlDomain });
|
||||||
const { visits } = reducer(buildState({ ...state, visits: visitsMocks }), createNewVisits([
|
const { visits } = reducer(buildState({ ...state, visits: visitsMocks }), createNewVisits([
|
||||||
Mock.of<CreateVisit>({ shortUrl, visit: { date: formatIsoDate(now) ?? undefined } }),
|
fromPartial({ shortUrl, visit: { date: formatIsoDate(now) ?? undefined } }),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
expect(visits).toHaveLength(expectedVisits);
|
expect(visits).toHaveLength(expectedVisits);
|
||||||
|
@ -153,7 +153,7 @@ describe('domainVisitsReducer', () => {
|
||||||
|
|
||||||
describe('getDomainVisits', () => {
|
describe('getDomainVisits', () => {
|
||||||
const dispatchMock = jest.fn();
|
const dispatchMock = jest.fn();
|
||||||
const getState = () => Mock.of<ShlinkState>({
|
const getState = () => fromPartial<ShlinkState>({
|
||||||
domainVisits: { cancelLoad: false },
|
domainVisits: { cancelLoad: false },
|
||||||
});
|
});
|
||||||
const domain = 'foo.com';
|
const domain = 'foo.com';
|
||||||
|
@ -183,12 +183,12 @@ describe('domainVisitsReducer', () => {
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
[
|
[
|
||||||
[Mock.of<Visit>({ date: formatISO(subDays(now, 20)) })],
|
[fromPartial<Visit>({ date: formatISO(subDays(now, 20)) })],
|
||||||
getDomainVisits.fallbackToInterval('last30Days'),
|
getDomainVisits.fallbackToInterval('last30Days'),
|
||||||
3,
|
3,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
[Mock.of<Visit>({ date: formatISO(subDays(now, 100)) })],
|
[fromPartial<Visit>({ date: formatISO(subDays(now, 100)) })],
|
||||||
getDomainVisits.fallbackToInterval('last180Days'),
|
getDomainVisits.fallbackToInterval('last180Days'),
|
||||||
3,
|
3,
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
import { fromPartial } from '@total-typescript/shoehorn';
|
||||||
import { addDays, formatISO, subDays } from 'date-fns';
|
import { addDays, formatISO, subDays } from 'date-fns';
|
||||||
import { Mock } from 'ts-mockery';
|
|
||||||
import type { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
|
import type { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
|
||||||
import type { ShlinkVisits } from '../../../src/api/types';
|
import type { ShlinkVisits } from '../../../src/api/types';
|
||||||
import type { ShlinkState } from '../../../src/container/types';
|
import type { ShlinkState } from '../../../src/container/types';
|
||||||
|
@ -16,16 +16,16 @@ import type { Visit } from '../../../src/visits/types';
|
||||||
|
|
||||||
describe('nonOrphanVisitsReducer', () => {
|
describe('nonOrphanVisitsReducer', () => {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const visitsMocks = rangeOf(2, () => Mock.all<Visit>());
|
const visitsMocks = rangeOf(2, () => fromPartial<Visit>({}));
|
||||||
const getNonOrphanVisitsCall = jest.fn();
|
const getNonOrphanVisitsCall = jest.fn();
|
||||||
const buildShlinkApiClient = () => Mock.of<ShlinkApiClient>({ getNonOrphanVisits: getNonOrphanVisitsCall });
|
const buildShlinkApiClient = () => fromPartial<ShlinkApiClient>({ getNonOrphanVisits: getNonOrphanVisitsCall });
|
||||||
const getNonOrphanVisits = getNonOrphanVisitsCreator(buildShlinkApiClient);
|
const getNonOrphanVisits = getNonOrphanVisitsCreator(buildShlinkApiClient);
|
||||||
const { reducer, cancelGetVisits: cancelGetNonOrphanVisits } = nonOrphanVisitsReducerCreator(getNonOrphanVisits);
|
const { reducer, cancelGetVisits: cancelGetNonOrphanVisits } = nonOrphanVisitsReducerCreator(getNonOrphanVisits);
|
||||||
|
|
||||||
beforeEach(jest.clearAllMocks);
|
beforeEach(jest.clearAllMocks);
|
||||||
|
|
||||||
describe('reducer', () => {
|
describe('reducer', () => {
|
||||||
const buildState = (data: Partial<VisitsInfo>) => Mock.of<VisitsInfo>(data);
|
const buildState = (data: Partial<VisitsInfo>) => fromPartial<VisitsInfo>(data);
|
||||||
|
|
||||||
it('returns loading on GET_NON_ORPHAN_VISITS_START', () => {
|
it('returns loading on GET_NON_ORPHAN_VISITS_START', () => {
|
||||||
const { loading } = reducer(buildState({ loading: false }), getNonOrphanVisits.pending('', {}));
|
const { loading } = reducer(buildState({ loading: false }), getNonOrphanVisits.pending('', {}));
|
||||||
|
@ -53,7 +53,7 @@ describe('nonOrphanVisitsReducer', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('return visits on GET_NON_ORPHAN_VISITS', () => {
|
it('return visits on GET_NON_ORPHAN_VISITS', () => {
|
||||||
const actionVisits = [Mock.all<Visit>(), Mock.all<Visit>()];
|
const actionVisits: Visit[] = [fromPartial({}), fromPartial({})];
|
||||||
const { loading, error, visits } = reducer(
|
const { loading, error, visits } = reducer(
|
||||||
buildState({ loading: true, error: false }),
|
buildState({ loading: true, error: false }),
|
||||||
getNonOrphanVisits.fulfilled({ visits: actionVisits }, '', {}),
|
getNonOrphanVisits.fulfilled({ visits: actionVisits }, '', {}),
|
||||||
|
@ -67,19 +67,19 @@ describe('nonOrphanVisitsReducer', () => {
|
||||||
it.each([
|
it.each([
|
||||||
[{}, visitsMocks.length + 2],
|
[{}, visitsMocks.length + 2],
|
||||||
[
|
[
|
||||||
Mock.of<VisitsInfo>({
|
fromPartial<VisitsInfo>({
|
||||||
query: { endDate: formatIsoDate(subDays(now, 1)) ?? undefined },
|
query: { endDate: formatIsoDate(subDays(now, 1)) ?? undefined },
|
||||||
}),
|
}),
|
||||||
visitsMocks.length,
|
visitsMocks.length,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
Mock.of<VisitsInfo>({
|
fromPartial<VisitsInfo>({
|
||||||
query: { startDate: formatIsoDate(addDays(now, 1)) ?? undefined },
|
query: { startDate: formatIsoDate(addDays(now, 1)) ?? undefined },
|
||||||
}),
|
}),
|
||||||
visitsMocks.length,
|
visitsMocks.length,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
Mock.of<VisitsInfo>({
|
fromPartial<VisitsInfo>({
|
||||||
query: {
|
query: {
|
||||||
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
||||||
endDate: formatIsoDate(subDays(now, 2)) ?? undefined,
|
endDate: formatIsoDate(subDays(now, 2)) ?? undefined,
|
||||||
|
@ -88,7 +88,7 @@ describe('nonOrphanVisitsReducer', () => {
|
||||||
visitsMocks.length,
|
visitsMocks.length,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
Mock.of<VisitsInfo>({
|
fromPartial<VisitsInfo>({
|
||||||
query: {
|
query: {
|
||||||
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
||||||
endDate: formatIsoDate(addDays(now, 3)) ?? undefined,
|
endDate: formatIsoDate(addDays(now, 3)) ?? undefined,
|
||||||
|
@ -98,7 +98,7 @@ describe('nonOrphanVisitsReducer', () => {
|
||||||
],
|
],
|
||||||
])('prepends new visits on CREATE_VISIT', (state, expectedVisits) => {
|
])('prepends new visits on CREATE_VISIT', (state, expectedVisits) => {
|
||||||
const prevState = buildState({ ...state, visits: visitsMocks });
|
const prevState = buildState({ ...state, visits: visitsMocks });
|
||||||
const visit = Mock.of<Visit>({ date: formatIsoDate(now) ?? undefined });
|
const visit = fromPartial<Visit>({ date: formatIsoDate(now) ?? undefined });
|
||||||
|
|
||||||
const { visits } = reducer(prevState, createNewVisits([{ visit }, { visit }]));
|
const { visits } = reducer(prevState, createNewVisits([{ visit }, { visit }]));
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ describe('nonOrphanVisitsReducer', () => {
|
||||||
|
|
||||||
describe('getNonOrphanVisits', () => {
|
describe('getNonOrphanVisits', () => {
|
||||||
const dispatchMock = jest.fn();
|
const dispatchMock = jest.fn();
|
||||||
const getState = () => Mock.of<ShlinkState>({
|
const getState = () => fromPartial<ShlinkState>({
|
||||||
orphanVisits: { cancelLoad: false },
|
orphanVisits: { cancelLoad: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -151,12 +151,12 @@ describe('nonOrphanVisitsReducer', () => {
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
[
|
[
|
||||||
[Mock.of<Visit>({ date: formatISO(subDays(now, 5)) })],
|
[fromPartial<Visit>({ date: formatISO(subDays(now, 5)) })],
|
||||||
getNonOrphanVisits.fallbackToInterval('last7Days'),
|
getNonOrphanVisits.fallbackToInterval('last7Days'),
|
||||||
3,
|
3,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
[Mock.of<Visit>({ date: formatISO(subDays(now, 200)) })],
|
[fromPartial<Visit>({ date: formatISO(subDays(now, 200)) })],
|
||||||
getNonOrphanVisits.fallbackToInterval('last365Days'),
|
getNonOrphanVisits.fallbackToInterval('last365Days'),
|
||||||
3,
|
3,
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
import { fromPartial } from '@total-typescript/shoehorn';
|
||||||
import { addDays, formatISO, subDays } from 'date-fns';
|
import { addDays, formatISO, subDays } from 'date-fns';
|
||||||
import { Mock } from 'ts-mockery';
|
|
||||||
import type { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
|
import type { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
|
||||||
import type { ShlinkVisits } from '../../../src/api/types';
|
import type { ShlinkVisits } from '../../../src/api/types';
|
||||||
import type { ShlinkState } from '../../../src/container/types';
|
import type { ShlinkState } from '../../../src/container/types';
|
||||||
|
@ -16,16 +16,16 @@ import type { Visit } from '../../../src/visits/types';
|
||||||
|
|
||||||
describe('orphanVisitsReducer', () => {
|
describe('orphanVisitsReducer', () => {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const visitsMocks = rangeOf(2, () => Mock.all<Visit>());
|
const visitsMocks = rangeOf(2, () => fromPartial<Visit>({}));
|
||||||
const getOrphanVisitsCall = jest.fn();
|
const getOrphanVisitsCall = jest.fn();
|
||||||
const buildShlinkApiClientMock = () => Mock.of<ShlinkApiClient>({ getOrphanVisits: getOrphanVisitsCall });
|
const buildShlinkApiClientMock = () => fromPartial<ShlinkApiClient>({ getOrphanVisits: getOrphanVisitsCall });
|
||||||
const getOrphanVisits = getOrphanVisitsCreator(buildShlinkApiClientMock);
|
const getOrphanVisits = getOrphanVisitsCreator(buildShlinkApiClientMock);
|
||||||
const { reducer, cancelGetVisits: cancelGetOrphanVisits } = orphanVisitsReducerCreator(getOrphanVisits);
|
const { reducer, cancelGetVisits: cancelGetOrphanVisits } = orphanVisitsReducerCreator(getOrphanVisits);
|
||||||
|
|
||||||
beforeEach(jest.clearAllMocks);
|
beforeEach(jest.clearAllMocks);
|
||||||
|
|
||||||
describe('reducer', () => {
|
describe('reducer', () => {
|
||||||
const buildState = (data: Partial<VisitsInfo>) => Mock.of<VisitsInfo>(data);
|
const buildState = (data: Partial<VisitsInfo>) => fromPartial<VisitsInfo>(data);
|
||||||
|
|
||||||
it('returns loading on GET_ORPHAN_VISITS_START', () => {
|
it('returns loading on GET_ORPHAN_VISITS_START', () => {
|
||||||
const { loading } = reducer(buildState({ loading: false }), getOrphanVisits.pending('', {}));
|
const { loading } = reducer(buildState({ loading: false }), getOrphanVisits.pending('', {}));
|
||||||
|
@ -53,7 +53,7 @@ describe('orphanVisitsReducer', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('return visits on GET_ORPHAN_VISITS', () => {
|
it('return visits on GET_ORPHAN_VISITS', () => {
|
||||||
const actionVisits = [Mock.all<Visit>(), Mock.all<Visit>()];
|
const actionVisits: Visit[] = [fromPartial({}), fromPartial({})];
|
||||||
const { loading, error, visits } = reducer(
|
const { loading, error, visits } = reducer(
|
||||||
buildState({ loading: true, error: false }),
|
buildState({ loading: true, error: false }),
|
||||||
getOrphanVisits.fulfilled({ visits: actionVisits }, '', {}),
|
getOrphanVisits.fulfilled({ visits: actionVisits }, '', {}),
|
||||||
|
@ -67,19 +67,19 @@ describe('orphanVisitsReducer', () => {
|
||||||
it.each([
|
it.each([
|
||||||
[{}, visitsMocks.length + 2],
|
[{}, visitsMocks.length + 2],
|
||||||
[
|
[
|
||||||
Mock.of<VisitsInfo>({
|
fromPartial<VisitsInfo>({
|
||||||
query: { endDate: formatIsoDate(subDays(now, 1)) ?? undefined },
|
query: { endDate: formatIsoDate(subDays(now, 1)) ?? undefined },
|
||||||
}),
|
}),
|
||||||
visitsMocks.length,
|
visitsMocks.length,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
Mock.of<VisitsInfo>({
|
fromPartial<VisitsInfo>({
|
||||||
query: { startDate: formatIsoDate(addDays(now, 1)) ?? undefined },
|
query: { startDate: formatIsoDate(addDays(now, 1)) ?? undefined },
|
||||||
}),
|
}),
|
||||||
visitsMocks.length,
|
visitsMocks.length,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
Mock.of<VisitsInfo>({
|
fromPartial<VisitsInfo>({
|
||||||
query: {
|
query: {
|
||||||
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
||||||
endDate: formatIsoDate(subDays(now, 2)) ?? undefined,
|
endDate: formatIsoDate(subDays(now, 2)) ?? undefined,
|
||||||
|
@ -88,7 +88,7 @@ describe('orphanVisitsReducer', () => {
|
||||||
visitsMocks.length,
|
visitsMocks.length,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
Mock.of<VisitsInfo>({
|
fromPartial<VisitsInfo>({
|
||||||
query: {
|
query: {
|
||||||
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
||||||
endDate: formatIsoDate(addDays(now, 3)) ?? undefined,
|
endDate: formatIsoDate(addDays(now, 3)) ?? undefined,
|
||||||
|
@ -98,7 +98,7 @@ describe('orphanVisitsReducer', () => {
|
||||||
],
|
],
|
||||||
])('prepends new visits on CREATE_VISIT', (state, expectedVisits) => {
|
])('prepends new visits on CREATE_VISIT', (state, expectedVisits) => {
|
||||||
const prevState = buildState({ ...state, visits: visitsMocks });
|
const prevState = buildState({ ...state, visits: visitsMocks });
|
||||||
const visit = Mock.of<Visit>({ date: formatIsoDate(now) ?? undefined });
|
const visit = fromPartial<Visit>({ date: formatIsoDate(now) ?? undefined });
|
||||||
|
|
||||||
const { visits } = reducer(prevState, createNewVisits([{ visit }, { visit }]));
|
const { visits } = reducer(prevState, createNewVisits([{ visit }, { visit }]));
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ describe('orphanVisitsReducer', () => {
|
||||||
|
|
||||||
describe('getOrphanVisits', () => {
|
describe('getOrphanVisits', () => {
|
||||||
const dispatchMock = jest.fn();
|
const dispatchMock = jest.fn();
|
||||||
const getState = () => Mock.of<ShlinkState>({
|
const getState = () => fromPartial<ShlinkState>({
|
||||||
orphanVisits: { cancelLoad: false },
|
orphanVisits: { cancelLoad: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -149,12 +149,12 @@ describe('orphanVisitsReducer', () => {
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
[
|
[
|
||||||
[Mock.of<Visit>({ date: formatISO(subDays(now, 5)) })],
|
[fromPartial<Visit>({ date: formatISO(subDays(now, 5)) })],
|
||||||
getOrphanVisits.fallbackToInterval('last7Days'),
|
getOrphanVisits.fallbackToInterval('last7Days'),
|
||||||
3,
|
3,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
[Mock.of<Visit>({ date: formatISO(subDays(now, 200)) })],
|
[fromPartial<Visit>({ date: formatISO(subDays(now, 200)) })],
|
||||||
getOrphanVisits.fallbackToInterval('last365Days'),
|
getOrphanVisits.fallbackToInterval('last365Days'),
|
||||||
3,
|
3,
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
import { fromPartial } from '@total-typescript/shoehorn';
|
||||||
import { addDays, formatISO, subDays } from 'date-fns';
|
import { addDays, formatISO, subDays } from 'date-fns';
|
||||||
import { Mock } from 'ts-mockery';
|
|
||||||
import type { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
|
import type { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
|
||||||
import type { ShlinkVisits } from '../../../src/api/types';
|
import type { ShlinkVisits } from '../../../src/api/types';
|
||||||
import type { ShlinkState } from '../../../src/container/types';
|
import type { ShlinkState } from '../../../src/container/types';
|
||||||
|
@ -13,20 +13,20 @@ import {
|
||||||
shortUrlVisitsReducerCreator,
|
shortUrlVisitsReducerCreator,
|
||||||
} from '../../../src/visits/reducers/shortUrlVisits';
|
} from '../../../src/visits/reducers/shortUrlVisits';
|
||||||
import { createNewVisits } from '../../../src/visits/reducers/visitCreation';
|
import { createNewVisits } from '../../../src/visits/reducers/visitCreation';
|
||||||
import type { CreateVisit, Visit } from '../../../src/visits/types';
|
import type { Visit } from '../../../src/visits/types';
|
||||||
|
|
||||||
describe('shortUrlVisitsReducer', () => {
|
describe('shortUrlVisitsReducer', () => {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const visitsMocks = rangeOf(2, () => Mock.all<Visit>());
|
const visitsMocks = rangeOf(2, () => fromPartial<Visit>({}));
|
||||||
const getShortUrlVisitsCall = jest.fn();
|
const getShortUrlVisitsCall = jest.fn();
|
||||||
const buildApiClientMock = () => Mock.of<ShlinkApiClient>({ getShortUrlVisits: getShortUrlVisitsCall });
|
const buildApiClientMock = () => fromPartial<ShlinkApiClient>({ getShortUrlVisits: getShortUrlVisitsCall });
|
||||||
const getShortUrlVisits = getShortUrlVisitsCreator(buildApiClientMock);
|
const getShortUrlVisits = getShortUrlVisitsCreator(buildApiClientMock);
|
||||||
const { reducer, cancelGetVisits: cancelGetShortUrlVisits } = shortUrlVisitsReducerCreator(getShortUrlVisits);
|
const { reducer, cancelGetVisits: cancelGetShortUrlVisits } = shortUrlVisitsReducerCreator(getShortUrlVisits);
|
||||||
|
|
||||||
beforeEach(jest.clearAllMocks);
|
beforeEach(jest.clearAllMocks);
|
||||||
|
|
||||||
describe('reducer', () => {
|
describe('reducer', () => {
|
||||||
const buildState = (data: Partial<ShortUrlVisits>) => Mock.of<ShortUrlVisits>(data);
|
const buildState = (data: Partial<ShortUrlVisits>) => fromPartial<ShortUrlVisits>(data);
|
||||||
|
|
||||||
it('returns loading on GET_SHORT_URL_VISITS_START', () => {
|
it('returns loading on GET_SHORT_URL_VISITS_START', () => {
|
||||||
const { loading } = reducer(buildState({ loading: false }), getShortUrlVisits.pending('', { shortCode: '' }));
|
const { loading } = reducer(buildState({ loading: false }), getShortUrlVisits.pending('', { shortCode: '' }));
|
||||||
|
@ -54,7 +54,7 @@ describe('shortUrlVisitsReducer', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('return visits on GET_SHORT_URL_VISITS', () => {
|
it('return visits on GET_SHORT_URL_VISITS', () => {
|
||||||
const actionVisits = [Mock.all<Visit>(), Mock.all<Visit>()];
|
const actionVisits: Visit[] = [fromPartial({}), fromPartial({})];
|
||||||
const { loading, error, visits } = reducer(
|
const { loading, error, visits } = reducer(
|
||||||
buildState({ loading: true, error: false }),
|
buildState({ loading: true, error: false }),
|
||||||
getShortUrlVisits.fulfilled({ visits: actionVisits }, '', { shortCode: '' }),
|
getShortUrlVisits.fulfilled({ visits: actionVisits }, '', { shortCode: '' }),
|
||||||
|
@ -69,21 +69,21 @@ describe('shortUrlVisitsReducer', () => {
|
||||||
[{ shortCode: 'abc123' }, visitsMocks.length + 1],
|
[{ shortCode: 'abc123' }, visitsMocks.length + 1],
|
||||||
[{ shortCode: 'def456' }, visitsMocks.length],
|
[{ shortCode: 'def456' }, visitsMocks.length],
|
||||||
[
|
[
|
||||||
Mock.of<ShortUrlVisits>({
|
fromPartial<ShortUrlVisits>({
|
||||||
shortCode: 'abc123',
|
shortCode: 'abc123',
|
||||||
query: { endDate: formatIsoDate(subDays(now, 1)) ?? undefined },
|
query: { endDate: formatIsoDate(subDays(now, 1)) ?? undefined },
|
||||||
}),
|
}),
|
||||||
visitsMocks.length,
|
visitsMocks.length,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
Mock.of<ShortUrlVisits>({
|
fromPartial<ShortUrlVisits>({
|
||||||
shortCode: 'abc123',
|
shortCode: 'abc123',
|
||||||
query: { startDate: formatIsoDate(addDays(now, 1)) ?? undefined },
|
query: { startDate: formatIsoDate(addDays(now, 1)) ?? undefined },
|
||||||
}),
|
}),
|
||||||
visitsMocks.length,
|
visitsMocks.length,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
Mock.of<ShortUrlVisits>({
|
fromPartial<ShortUrlVisits>({
|
||||||
shortCode: 'abc123',
|
shortCode: 'abc123',
|
||||||
query: {
|
query: {
|
||||||
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
||||||
|
@ -93,7 +93,7 @@ describe('shortUrlVisitsReducer', () => {
|
||||||
visitsMocks.length,
|
visitsMocks.length,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
Mock.of<ShortUrlVisits>({
|
fromPartial<ShortUrlVisits>({
|
||||||
shortCode: 'abc123',
|
shortCode: 'abc123',
|
||||||
query: {
|
query: {
|
||||||
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
||||||
|
@ -103,7 +103,7 @@ describe('shortUrlVisitsReducer', () => {
|
||||||
visitsMocks.length + 1,
|
visitsMocks.length + 1,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
Mock.of<ShortUrlVisits>({
|
fromPartial<ShortUrlVisits>({
|
||||||
shortCode: 'def456',
|
shortCode: 'def456',
|
||||||
query: {
|
query: {
|
||||||
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
||||||
|
@ -123,7 +123,7 @@ describe('shortUrlVisitsReducer', () => {
|
||||||
|
|
||||||
const { visits } = reducer(
|
const { visits } = reducer(
|
||||||
prevState,
|
prevState,
|
||||||
createNewVisits([Mock.of<CreateVisit>({ shortUrl, visit: { date: formatIsoDate(now) ?? undefined } })]),
|
createNewVisits([fromPartial({ shortUrl, visit: { date: formatIsoDate(now) ?? undefined } })]),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(visits).toHaveLength(expectedVisits);
|
expect(visits).toHaveLength(expectedVisits);
|
||||||
|
@ -144,8 +144,8 @@ describe('shortUrlVisitsReducer', () => {
|
||||||
|
|
||||||
describe('getShortUrlVisits', () => {
|
describe('getShortUrlVisits', () => {
|
||||||
const dispatchMock = jest.fn();
|
const dispatchMock = jest.fn();
|
||||||
const getState = () => Mock.of<ShlinkState>({
|
const getState = () => fromPartial<ShlinkState>({
|
||||||
shortUrlVisits: Mock.of<ShortUrlVisits>({ cancelLoad: false }),
|
shortUrlVisits: { cancelLoad: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
|
@ -197,12 +197,12 @@ describe('shortUrlVisitsReducer', () => {
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
[
|
[
|
||||||
[Mock.of<Visit>({ date: formatISO(subDays(now, 5)) })],
|
[fromPartial<Visit>({ date: formatISO(subDays(now, 5)) })],
|
||||||
getShortUrlVisits.fallbackToInterval('last7Days'),
|
getShortUrlVisits.fallbackToInterval('last7Days'),
|
||||||
3,
|
3,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
[Mock.of<Visit>({ date: formatISO(subDays(now, 200)) })],
|
[fromPartial<Visit>({ date: formatISO(subDays(now, 200)) })],
|
||||||
getShortUrlVisits.fallbackToInterval('last365Days'),
|
getShortUrlVisits.fallbackToInterval('last365Days'),
|
||||||
3,
|
3,
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
import { fromPartial } from '@total-typescript/shoehorn';
|
||||||
import { addDays, formatISO, subDays } from 'date-fns';
|
import { addDays, formatISO, subDays } from 'date-fns';
|
||||||
import { Mock } from 'ts-mockery';
|
|
||||||
import type { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
|
import type { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
|
||||||
import type { ShlinkVisits } from '../../../src/api/types';
|
import type { ShlinkVisits } from '../../../src/api/types';
|
||||||
import type { ShlinkState } from '../../../src/container/types';
|
import type { ShlinkState } from '../../../src/container/types';
|
||||||
|
@ -13,20 +13,20 @@ import {
|
||||||
tagVisitsReducerCreator,
|
tagVisitsReducerCreator,
|
||||||
} from '../../../src/visits/reducers/tagVisits';
|
} from '../../../src/visits/reducers/tagVisits';
|
||||||
import { createNewVisits } from '../../../src/visits/reducers/visitCreation';
|
import { createNewVisits } from '../../../src/visits/reducers/visitCreation';
|
||||||
import type { CreateVisit, Visit } from '../../../src/visits/types';
|
import type { Visit } from '../../../src/visits/types';
|
||||||
|
|
||||||
describe('tagVisitsReducer', () => {
|
describe('tagVisitsReducer', () => {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const visitsMocks = rangeOf(2, () => Mock.all<Visit>());
|
const visitsMocks = rangeOf(2, () => fromPartial<Visit>({}));
|
||||||
const getTagVisitsCall = jest.fn();
|
const getTagVisitsCall = jest.fn();
|
||||||
const buildShlinkApiClientMock = () => Mock.of<ShlinkApiClient>({ getTagVisits: getTagVisitsCall });
|
const buildShlinkApiClientMock = () => fromPartial<ShlinkApiClient>({ getTagVisits: getTagVisitsCall });
|
||||||
const getTagVisits = getTagVisitsCreator(buildShlinkApiClientMock);
|
const getTagVisits = getTagVisitsCreator(buildShlinkApiClientMock);
|
||||||
const { reducer, cancelGetVisits: cancelGetTagVisits } = tagVisitsReducerCreator(getTagVisits);
|
const { reducer, cancelGetVisits: cancelGetTagVisits } = tagVisitsReducerCreator(getTagVisits);
|
||||||
|
|
||||||
beforeEach(jest.clearAllMocks);
|
beforeEach(jest.clearAllMocks);
|
||||||
|
|
||||||
describe('reducer', () => {
|
describe('reducer', () => {
|
||||||
const buildState = (data: Partial<TagVisits>) => Mock.of<TagVisits>(data);
|
const buildState = (data: Partial<TagVisits>) => fromPartial<TagVisits>(data);
|
||||||
|
|
||||||
it('returns loading on GET_TAG_VISITS_START', () => {
|
it('returns loading on GET_TAG_VISITS_START', () => {
|
||||||
const { loading } = reducer(buildState({ loading: false }), getTagVisits.pending('', { tag: '' }));
|
const { loading } = reducer(buildState({ loading: false }), getTagVisits.pending('', { tag: '' }));
|
||||||
|
@ -54,7 +54,7 @@ describe('tagVisitsReducer', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('return visits on GET_TAG_VISITS', () => {
|
it('return visits on GET_TAG_VISITS', () => {
|
||||||
const actionVisits = [Mock.all<Visit>(), Mock.all<Visit>()];
|
const actionVisits: Visit[] = [fromPartial({}), fromPartial({})];
|
||||||
const { loading, error, visits } = reducer(
|
const { loading, error, visits } = reducer(
|
||||||
buildState({ loading: true, error: false }),
|
buildState({ loading: true, error: false }),
|
||||||
getTagVisits.fulfilled({ visits: actionVisits }, '', { tag: '' }),
|
getTagVisits.fulfilled({ visits: actionVisits }, '', { tag: '' }),
|
||||||
|
@ -69,21 +69,21 @@ describe('tagVisitsReducer', () => {
|
||||||
[{ tag: 'foo' }, visitsMocks.length + 1],
|
[{ tag: 'foo' }, visitsMocks.length + 1],
|
||||||
[{ tag: 'bar' }, visitsMocks.length],
|
[{ tag: 'bar' }, visitsMocks.length],
|
||||||
[
|
[
|
||||||
Mock.of<TagVisits>({
|
fromPartial<TagVisits>({
|
||||||
tag: 'foo',
|
tag: 'foo',
|
||||||
query: { endDate: formatIsoDate(subDays(now, 1)) ?? undefined },
|
query: { endDate: formatIsoDate(subDays(now, 1)) ?? undefined },
|
||||||
}),
|
}),
|
||||||
visitsMocks.length,
|
visitsMocks.length,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
Mock.of<TagVisits>({
|
fromPartial<TagVisits>({
|
||||||
tag: 'foo',
|
tag: 'foo',
|
||||||
query: { startDate: formatIsoDate(addDays(now, 1)) ?? undefined },
|
query: { startDate: formatIsoDate(addDays(now, 1)) ?? undefined },
|
||||||
}),
|
}),
|
||||||
visitsMocks.length,
|
visitsMocks.length,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
Mock.of<TagVisits>({
|
fromPartial<TagVisits>({
|
||||||
tag: 'foo',
|
tag: 'foo',
|
||||||
query: {
|
query: {
|
||||||
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
||||||
|
@ -93,7 +93,7 @@ describe('tagVisitsReducer', () => {
|
||||||
visitsMocks.length,
|
visitsMocks.length,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
Mock.of<TagVisits>({
|
fromPartial<TagVisits>({
|
||||||
tag: 'foo',
|
tag: 'foo',
|
||||||
query: {
|
query: {
|
||||||
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
||||||
|
@ -103,7 +103,7 @@ describe('tagVisitsReducer', () => {
|
||||||
visitsMocks.length + 1,
|
visitsMocks.length + 1,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
Mock.of<TagVisits>({
|
fromPartial<TagVisits>({
|
||||||
tag: 'bar',
|
tag: 'bar',
|
||||||
query: {
|
query: {
|
||||||
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
startDate: formatIsoDate(subDays(now, 5)) ?? undefined,
|
||||||
|
@ -123,7 +123,7 @@ describe('tagVisitsReducer', () => {
|
||||||
|
|
||||||
const { visits } = reducer(
|
const { visits } = reducer(
|
||||||
prevState,
|
prevState,
|
||||||
createNewVisits([Mock.of<CreateVisit>({ shortUrl, visit: { date: formatIsoDate(now) ?? undefined } })]),
|
createNewVisits([fromPartial({ shortUrl, visit: { date: formatIsoDate(now) ?? undefined } })]),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(visits).toHaveLength(expectedVisits);
|
expect(visits).toHaveLength(expectedVisits);
|
||||||
|
@ -144,7 +144,7 @@ describe('tagVisitsReducer', () => {
|
||||||
|
|
||||||
describe('getTagVisits', () => {
|
describe('getTagVisits', () => {
|
||||||
const dispatchMock = jest.fn();
|
const dispatchMock = jest.fn();
|
||||||
const getState = () => Mock.of<ShlinkState>({
|
const getState = () => fromPartial<ShlinkState>({
|
||||||
tagVisits: { cancelLoad: false },
|
tagVisits: { cancelLoad: false },
|
||||||
});
|
});
|
||||||
const tag = 'foo';
|
const tag = 'foo';
|
||||||
|
@ -174,12 +174,12 @@ describe('tagVisitsReducer', () => {
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
[
|
[
|
||||||
[Mock.of<Visit>({ date: formatISO(subDays(now, 20)) })],
|
[fromPartial<Visit>({ date: formatISO(subDays(now, 20)) })],
|
||||||
getTagVisits.fallbackToInterval('last30Days'),
|
getTagVisits.fallbackToInterval('last30Days'),
|
||||||
3,
|
3,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
[Mock.of<Visit>({ date: formatISO(subDays(now, 100)) })],
|
[fromPartial<Visit>({ date: formatISO(subDays(now, 100)) })],
|
||||||
getTagVisits.fallbackToInterval('last180Days'),
|
getTagVisits.fallbackToInterval('last180Days'),
|
||||||
3,
|
3,
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { Mock } from 'ts-mockery';
|
import { fromPartial } from '@total-typescript/shoehorn';
|
||||||
import type { ShortUrl } from '../../../src/short-urls/data';
|
import type { ShortUrl } from '../../../src/short-urls/data';
|
||||||
import { createNewVisits } from '../../../src/visits/reducers/visitCreation';
|
import { createNewVisits } from '../../../src/visits/reducers/visitCreation';
|
||||||
import type { Visit } from '../../../src/visits/types';
|
import type { Visit } from '../../../src/visits/types';
|
||||||
|
|
||||||
describe('visitCreationReducer', () => {
|
describe('visitCreationReducer', () => {
|
||||||
describe('createNewVisits', () => {
|
describe('createNewVisits', () => {
|
||||||
const shortUrl = Mock.all<ShortUrl>();
|
const shortUrl = fromPartial<ShortUrl>({});
|
||||||
const visit = Mock.all<Visit>();
|
const visit = fromPartial<Visit>({});
|
||||||
|
|
||||||
it('just returns the action with proper type', () => {
|
it('just returns the action with proper type', () => {
|
||||||
const { payload } = createNewVisits([{ shortUrl, visit }]);
|
const { payload } = createNewVisits([{ shortUrl, visit }]);
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import { Mock } from 'ts-mockery';
|
import { fromPartial } from '@total-typescript/shoehorn';
|
||||||
import type { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
|
import type { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
|
||||||
import type { ShlinkVisitsOverview } from '../../../src/api/types';
|
import type { ShlinkVisitsOverview } from '../../../src/api/types';
|
||||||
import type { ShlinkState } from '../../../src/container/types';
|
import type { ShlinkState } from '../../../src/container/types';
|
||||||
import { createNewVisits } from '../../../src/visits/reducers/visitCreation';
|
import { createNewVisits } from '../../../src/visits/reducers/visitCreation';
|
||||||
import type {
|
import type {
|
||||||
ParsedVisitsOverview,
|
|
||||||
PartialVisitsSummary,
|
PartialVisitsSummary,
|
||||||
VisitsOverview,
|
VisitsOverview,
|
||||||
} from '../../../src/visits/reducers/visitsOverview';
|
} from '../../../src/visits/reducers/visitsOverview';
|
||||||
|
@ -12,18 +11,18 @@ import {
|
||||||
loadVisitsOverview as loadVisitsOverviewCreator,
|
loadVisitsOverview as loadVisitsOverviewCreator,
|
||||||
visitsOverviewReducerCreator,
|
visitsOverviewReducerCreator,
|
||||||
} from '../../../src/visits/reducers/visitsOverview';
|
} from '../../../src/visits/reducers/visitsOverview';
|
||||||
import type { CreateVisit, OrphanVisit, Visit } from '../../../src/visits/types';
|
import type { OrphanVisit } from '../../../src/visits/types';
|
||||||
|
|
||||||
describe('visitsOverviewReducer', () => {
|
describe('visitsOverviewReducer', () => {
|
||||||
const getVisitsOverview = jest.fn();
|
const getVisitsOverview = jest.fn();
|
||||||
const buildApiClientMock = () => Mock.of<ShlinkApiClient>({ getVisitsOverview });
|
const buildApiClientMock = () => fromPartial<ShlinkApiClient>({ getVisitsOverview });
|
||||||
const loadVisitsOverview = loadVisitsOverviewCreator(buildApiClientMock);
|
const loadVisitsOverview = loadVisitsOverviewCreator(buildApiClientMock);
|
||||||
const { reducer } = visitsOverviewReducerCreator(loadVisitsOverview);
|
const { reducer } = visitsOverviewReducerCreator(loadVisitsOverview);
|
||||||
|
|
||||||
beforeEach(jest.clearAllMocks);
|
beforeEach(jest.clearAllMocks);
|
||||||
|
|
||||||
describe('reducer', () => {
|
describe('reducer', () => {
|
||||||
const state = (payload: Partial<VisitsOverview> = {}) => Mock.of<VisitsOverview>(payload);
|
const state = (payload: Partial<VisitsOverview> = {}) => fromPartial<VisitsOverview>(payload);
|
||||||
|
|
||||||
it('returns loading on GET_OVERVIEW_START', () => {
|
it('returns loading on GET_OVERVIEW_START', () => {
|
||||||
const { loading } = reducer(
|
const { loading } = reducer(
|
||||||
|
@ -45,7 +44,7 @@ describe('visitsOverviewReducer', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('return visits overview on GET_OVERVIEW', () => {
|
it('return visits overview on GET_OVERVIEW', () => {
|
||||||
const action = loadVisitsOverview.fulfilled(Mock.of<ParsedVisitsOverview>({
|
const action = loadVisitsOverview.fulfilled(fromPartial({
|
||||||
nonOrphanVisits: { total: 100 },
|
nonOrphanVisits: { total: 100 },
|
||||||
}), 'requestId');
|
}), 'requestId');
|
||||||
const { loading, error, nonOrphanVisits } = reducer(state({ loading: true, error: false }), action);
|
const { loading, error, nonOrphanVisits } = reducer(state({ loading: true, error: false }), action);
|
||||||
|
@ -65,17 +64,11 @@ describe('visitsOverviewReducer', () => {
|
||||||
orphanVisits: { total: providedOrphanVisitsCount },
|
orphanVisits: { total: providedOrphanVisitsCount },
|
||||||
}),
|
}),
|
||||||
createNewVisits([
|
createNewVisits([
|
||||||
Mock.of<CreateVisit>({ visit: Mock.all<Visit>() }),
|
fromPartial({ visit: {} }),
|
||||||
Mock.of<CreateVisit>({ visit: Mock.all<Visit>() }),
|
fromPartial({ visit: {} }),
|
||||||
Mock.of<CreateVisit>({
|
fromPartial({ visit: fromPartial<OrphanVisit>({ visitedUrl: '' }) }),
|
||||||
visit: Mock.of<OrphanVisit>({ visitedUrl: '' }),
|
fromPartial({ visit: fromPartial<OrphanVisit>({ visitedUrl: '' }) }),
|
||||||
}),
|
fromPartial({ visit: fromPartial<OrphanVisit>({ visitedUrl: '' }) }),
|
||||||
Mock.of<CreateVisit>({
|
|
||||||
visit: Mock.of<OrphanVisit>({ visitedUrl: '' }),
|
|
||||||
}),
|
|
||||||
Mock.of<CreateVisit>({
|
|
||||||
visit: Mock.of<OrphanVisit>({ visitedUrl: '' }),
|
|
||||||
}),
|
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -120,18 +113,12 @@ describe('visitsOverviewReducer', () => {
|
||||||
orphanVisits: { total: 200, ...initialOrphanVisits },
|
orphanVisits: { total: 200, ...initialOrphanVisits },
|
||||||
}),
|
}),
|
||||||
createNewVisits([
|
createNewVisits([
|
||||||
Mock.of<CreateVisit>({ visit: Mock.all<Visit>() }),
|
fromPartial({ visit: {} }),
|
||||||
Mock.of<CreateVisit>({ visit: Mock.of<Visit>({ potentialBot: true }) }),
|
fromPartial({ visit: { potentialBot: true } }),
|
||||||
Mock.of<CreateVisit>({ visit: Mock.of<Visit>({ potentialBot: true }) }),
|
fromPartial({ visit: { potentialBot: true } }),
|
||||||
Mock.of<CreateVisit>({
|
fromPartial({ visit: fromPartial<OrphanVisit>({ visitedUrl: '' }) }),
|
||||||
visit: Mock.of<OrphanVisit>({ visitedUrl: '' }),
|
fromPartial({ visit: fromPartial<OrphanVisit>({ visitedUrl: '' }) }),
|
||||||
}),
|
fromPartial({ visit: fromPartial<OrphanVisit>({ visitedUrl: '', potentialBot: true }) }),
|
||||||
Mock.of<CreateVisit>({
|
|
||||||
visit: Mock.of<OrphanVisit>({ visitedUrl: '' }),
|
|
||||||
}),
|
|
||||||
Mock.of<CreateVisit>({
|
|
||||||
visit: Mock.of<OrphanVisit>({ visitedUrl: '', potentialBot: true }),
|
|
||||||
}),
|
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -142,7 +129,7 @@ describe('visitsOverviewReducer', () => {
|
||||||
|
|
||||||
describe('loadVisitsOverview', () => {
|
describe('loadVisitsOverview', () => {
|
||||||
const dispatchMock = jest.fn();
|
const dispatchMock = jest.fn();
|
||||||
const getState = () => Mock.of<ShlinkState>();
|
const getState = () => fromPartial<ShlinkState>({});
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
[
|
[
|
||||||
|
@ -167,7 +154,7 @@ describe('visitsOverviewReducer', () => {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
])('dispatches start and success when promise is resolved', async (serverResult, dispatchedPayload) => {
|
])('dispatches start and success when promise is resolved', async (serverResult, dispatchedPayload) => {
|
||||||
const resolvedOverview = Mock.of<ShlinkVisitsOverview>(serverResult);
|
const resolvedOverview = fromPartial<ShlinkVisitsOverview>(serverResult);
|
||||||
getVisitsOverview.mockResolvedValue(resolvedOverview);
|
getVisitsOverview.mockResolvedValue(resolvedOverview);
|
||||||
|
|
||||||
await loadVisitsOverview()(dispatchMock, getState, {});
|
await loadVisitsOverview()(dispatchMock, getState, {});
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { Mock } from 'ts-mockery';
|
import { fromPartial } from '@total-typescript/shoehorn';
|
||||||
import { normalizeVisits, processStatsFromVisits } from '../../../src/visits/services/VisitsParser';
|
import { normalizeVisits, processStatsFromVisits } from '../../../src/visits/services/VisitsParser';
|
||||||
import type { OrphanVisit, Visit, VisitsStats } from '../../../src/visits/types';
|
import type { OrphanVisit, Visit, VisitsStats } from '../../../src/visits/types';
|
||||||
|
|
||||||
describe('VisitsParser', () => {
|
describe('VisitsParser', () => {
|
||||||
const visits: Visit[] = [
|
const visits: Visit[] = [
|
||||||
Mock.of<Visit>({
|
fromPartial({
|
||||||
userAgent: 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0',
|
userAgent: 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0',
|
||||||
referer: 'https://google.com',
|
referer: 'https://google.com',
|
||||||
potentialBot: false,
|
potentialBot: false,
|
||||||
|
@ -15,7 +15,7 @@ describe('VisitsParser', () => {
|
||||||
longitude: -543.21,
|
longitude: -543.21,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
Mock.of<Visit>({
|
fromPartial({
|
||||||
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0',
|
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0',
|
||||||
referer: 'https://google.com',
|
referer: 'https://google.com',
|
||||||
potentialBot: false,
|
potentialBot: false,
|
||||||
|
@ -26,7 +26,7 @@ describe('VisitsParser', () => {
|
||||||
longitude: 6758,
|
longitude: 6758,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
Mock.of<Visit>({
|
fromPartial({
|
||||||
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36',
|
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36',
|
||||||
potentialBot: false,
|
potentialBot: false,
|
||||||
visitLocation: {
|
visitLocation: {
|
||||||
|
@ -34,7 +34,7 @@ describe('VisitsParser', () => {
|
||||||
cityName: '',
|
cityName: '',
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
Mock.of<Visit>({
|
fromPartial({
|
||||||
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36',
|
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36',
|
||||||
referer: 'https://m.facebook.com',
|
referer: 'https://m.facebook.com',
|
||||||
potentialBot: false,
|
potentialBot: false,
|
||||||
|
@ -45,13 +45,13 @@ describe('VisitsParser', () => {
|
||||||
longitude: -543.21,
|
longitude: -543.21,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
Mock.of<Visit>({
|
fromPartial({
|
||||||
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36 OPR/38.0.2220.41',
|
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36 OPR/38.0.2220.41',
|
||||||
potentialBot: true,
|
potentialBot: true,
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
const orphanVisits: OrphanVisit[] = [
|
const orphanVisits: OrphanVisit[] = [
|
||||||
Mock.of<OrphanVisit>({
|
fromPartial({
|
||||||
type: 'base_url',
|
type: 'base_url',
|
||||||
visitedUrl: 'foo',
|
visitedUrl: 'foo',
|
||||||
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0',
|
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0',
|
||||||
|
@ -64,12 +64,12 @@ describe('VisitsParser', () => {
|
||||||
longitude: 6758,
|
longitude: 6758,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
Mock.of<OrphanVisit>({
|
fromPartial({
|
||||||
type: 'regular_404',
|
type: 'regular_404',
|
||||||
visitedUrl: 'bar',
|
visitedUrl: 'bar',
|
||||||
potentialBot: true,
|
potentialBot: true,
|
||||||
}),
|
}),
|
||||||
Mock.of<OrphanVisit>({
|
fromPartial({
|
||||||
type: 'invalid_short_url',
|
type: 'invalid_short_url',
|
||||||
visitedUrl: 'bar',
|
visitedUrl: 'bar',
|
||||||
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36',
|
userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36',
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Mock } from 'ts-mockery';
|
import { fromPartial } from '@total-typescript/shoehorn';
|
||||||
import type { ShlinkVisitsParams } from '../../../src/api/types';
|
import type { ShlinkVisitsParams } from '../../../src/api/types';
|
||||||
import { formatIsoDate, parseDate } from '../../../src/utils/helpers/date';
|
import { formatIsoDate, parseDate } from '../../../src/utils/helpers/date';
|
||||||
import type { CreateVisit, OrphanVisit, Visit, VisitsParams } from '../../../src/visits/types';
|
import type { CreateVisit, OrphanVisit, VisitsParams } from '../../../src/visits/types';
|
||||||
import type { GroupedNewVisits } from '../../../src/visits/types/helpers';
|
import type { GroupedNewVisits } from '../../../src/visits/types/helpers';
|
||||||
import { groupNewVisitsByType, toApiParams } from '../../../src/visits/types/helpers';
|
import { groupNewVisitsByType, toApiParams } from '../../../src/visits/types/helpers';
|
||||||
|
|
||||||
|
@ -11,19 +11,15 @@ describe('visitsTypeHelpers', () => {
|
||||||
[[], { orphanVisits: [], nonOrphanVisits: [] }],
|
[[], { orphanVisits: [], nonOrphanVisits: [] }],
|
||||||
((): [CreateVisit[], GroupedNewVisits] => {
|
((): [CreateVisit[], GroupedNewVisits] => {
|
||||||
const orphanVisits: CreateVisit[] = [
|
const orphanVisits: CreateVisit[] = [
|
||||||
Mock.of<CreateVisit>({
|
fromPartial({ visit: fromPartial<OrphanVisit>({ visitedUrl: '' }) }),
|
||||||
visit: Mock.of<OrphanVisit>({ visitedUrl: '' }),
|
fromPartial({ visit: fromPartial<OrphanVisit>({ visitedUrl: '' }) }),
|
||||||
}),
|
|
||||||
Mock.of<CreateVisit>({
|
|
||||||
visit: Mock.of<OrphanVisit>({ visitedUrl: '' }),
|
|
||||||
}),
|
|
||||||
];
|
];
|
||||||
const nonOrphanVisits: CreateVisit[] = [
|
const nonOrphanVisits: CreateVisit[] = [
|
||||||
Mock.of<CreateVisit>({ visit: Mock.all<Visit>() }),
|
fromPartial({ visit: {} }),
|
||||||
Mock.of<CreateVisit>({ visit: Mock.all<Visit>() }),
|
fromPartial({ visit: {} }),
|
||||||
Mock.of<CreateVisit>({ visit: Mock.all<Visit>() }),
|
fromPartial({ visit: {} }),
|
||||||
Mock.of<CreateVisit>({ visit: Mock.all<Visit>() }),
|
fromPartial({ visit: {} }),
|
||||||
Mock.of<CreateVisit>({ visit: Mock.all<Visit>() }),
|
fromPartial({ visit: {} }),
|
||||||
];
|
];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -33,24 +29,18 @@ describe('visitsTypeHelpers', () => {
|
||||||
})(),
|
})(),
|
||||||
((): [CreateVisit[], GroupedNewVisits] => {
|
((): [CreateVisit[], GroupedNewVisits] => {
|
||||||
const orphanVisits: CreateVisit[] = [
|
const orphanVisits: CreateVisit[] = [
|
||||||
Mock.of<CreateVisit>({
|
fromPartial({ visit: fromPartial<OrphanVisit>({ visitedUrl: '' }) }),
|
||||||
visit: Mock.of<OrphanVisit>({ visitedUrl: '' }),
|
fromPartial({ visit: fromPartial<OrphanVisit>({ visitedUrl: '' }) }),
|
||||||
}),
|
fromPartial({ visit: fromPartial<OrphanVisit>({ visitedUrl: '' }) }),
|
||||||
Mock.of<CreateVisit>({
|
|
||||||
visit: Mock.of<OrphanVisit>({ visitedUrl: '' }),
|
|
||||||
}),
|
|
||||||
Mock.of<CreateVisit>({
|
|
||||||
visit: Mock.of<OrphanVisit>({ visitedUrl: '' }),
|
|
||||||
}),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return [orphanVisits, { orphanVisits, nonOrphanVisits: [] }];
|
return [orphanVisits, { orphanVisits, nonOrphanVisits: [] }];
|
||||||
})(),
|
})(),
|
||||||
((): [CreateVisit[], GroupedNewVisits] => {
|
((): [CreateVisit[], GroupedNewVisits] => {
|
||||||
const nonOrphanVisits: CreateVisit[] = [
|
const nonOrphanVisits: CreateVisit[] = [
|
||||||
Mock.of<CreateVisit>({ visit: Mock.all<Visit>() }),
|
fromPartial({ visit: {} }),
|
||||||
Mock.of<CreateVisit>({ visit: Mock.all<Visit>() }),
|
fromPartial({ visit: {} }),
|
||||||
Mock.of<CreateVisit>({ visit: Mock.all<Visit>() }),
|
fromPartial({ visit: {} }),
|
||||||
];
|
];
|
||||||
|
|
||||||
return [nonOrphanVisits, { orphanVisits: [], nonOrphanVisits }];
|
return [nonOrphanVisits, { orphanVisits: [], nonOrphanVisits }];
|
||||||
|
|
Loading…
Reference in a new issue