mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-11 10:03:51 +00:00
Updated to airbnb coding styles
This commit is contained in:
@@ -60,7 +60,7 @@ describe('<EditShortUrl />', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[ undefined, { longUrl: '', validateUrl: true }, true ],
|
||||
[undefined, { longUrl: '', validateUrl: true }, true],
|
||||
[
|
||||
Mock.of<ShortUrl>({ meta: {} }),
|
||||
{
|
||||
|
||||
@@ -12,22 +12,22 @@ describe('<Paginator />', () => {
|
||||
afterEach(() => wrapper?.unmount());
|
||||
|
||||
it.each([
|
||||
[ undefined ],
|
||||
[ buildPaginator() ],
|
||||
[ buildPaginator(0) ],
|
||||
[ buildPaginator(1) ],
|
||||
[undefined],
|
||||
[buildPaginator()],
|
||||
[buildPaginator(0)],
|
||||
[buildPaginator(1)],
|
||||
])('renders nothing if the number of pages is below 2', (paginator) => {
|
||||
wrapper = shallow(<Paginator serverId="abc123" paginator={paginator} />);
|
||||
expect(wrapper.text()).toEqual('');
|
||||
});
|
||||
|
||||
it.each([
|
||||
[ buildPaginator(2), 4, 0 ],
|
||||
[ buildPaginator(3), 5, 0 ],
|
||||
[ buildPaginator(4), 6, 0 ],
|
||||
[ buildPaginator(5), 7, 1 ],
|
||||
[ buildPaginator(6), 7, 1 ],
|
||||
[ buildPaginator(23), 7, 1 ],
|
||||
[buildPaginator(2), 4, 0],
|
||||
[buildPaginator(3), 5, 0],
|
||||
[buildPaginator(4), 6, 0],
|
||||
[buildPaginator(5), 7, 1],
|
||||
[buildPaginator(6), 7, 1],
|
||||
[buildPaginator(23), 7, 1],
|
||||
])('renders previous, next and the list of pages, with ellipses when expected', (
|
||||
paginator,
|
||||
expectedPages,
|
||||
|
||||
@@ -41,7 +41,7 @@ describe('<ShortUrlForm />', () => {
|
||||
const validUntil = parseDate('2017-01-06', 'yyyy-MM-dd');
|
||||
|
||||
wrapper.find(Input).first().simulate('change', { target: { value: 'https://long-domain.com/foo/bar' } });
|
||||
wrapper.find('TagsSelector').simulate('change', [ 'tag_foo', 'tag_bar' ]);
|
||||
wrapper.find('TagsSelector').simulate('change', ['tag_foo', 'tag_bar']);
|
||||
wrapper.find('#customSlug').simulate('change', { target: { value: 'my-slug' } });
|
||||
wrapper.find(DomainSelector).simulate('change', 'example.com');
|
||||
wrapper.find('#maxVisits').simulate('change', { target: { value: '20' } });
|
||||
@@ -53,7 +53,7 @@ describe('<ShortUrlForm />', () => {
|
||||
expect(createShortUrl).toHaveBeenCalledTimes(1);
|
||||
expect(createShortUrl).toHaveBeenCalledWith({
|
||||
longUrl: 'https://long-domain.com/foo/bar',
|
||||
tags: [ 'tag_foo', 'tag_bar' ],
|
||||
tags: ['tag_foo', 'tag_bar'],
|
||||
customSlug: 'my-slug',
|
||||
domain: 'example.com',
|
||||
validSince: formatISO(validSince),
|
||||
@@ -66,12 +66,12 @@ describe('<ShortUrlForm />', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[ null, 'create' as Mode, 4 ],
|
||||
[ null, 'create-basic' as Mode, 0 ],
|
||||
[ Mock.of<ReachableServer>({ version: '2.6.0' }), 'create' as Mode, 4 ],
|
||||
[ Mock.of<ReachableServer>({ version: '2.5.0' }), 'create' as Mode, 4 ],
|
||||
[ Mock.of<ReachableServer>({ version: '2.6.0' }), 'edit' as Mode, 4 ],
|
||||
[ Mock.of<ReachableServer>({ version: '2.5.0' }), 'edit' as Mode, 3 ],
|
||||
[null, 'create' as Mode, 4],
|
||||
[null, 'create-basic' as Mode, 0],
|
||||
[Mock.of<ReachableServer>({ version: '2.6.0' }), 'create' as Mode, 4],
|
||||
[Mock.of<ReachableServer>({ version: '2.5.0' }), 'create' as Mode, 4],
|
||||
[Mock.of<ReachableServer>({ version: '2.6.0' }), 'edit' as Mode, 4],
|
||||
[Mock.of<ReachableServer>({ version: '2.5.0' }), 'edit' as Mode, 3],
|
||||
])(
|
||||
'renders expected amount of cards based on server capabilities and mode',
|
||||
(selectedServer, mode, expectedAmountOfCards) => {
|
||||
@@ -83,16 +83,16 @@ describe('<ShortUrlForm />', () => {
|
||||
);
|
||||
|
||||
it.each([
|
||||
[ null, 'new title', 'new title' ],
|
||||
[ undefined, 'new title', 'new title' ],
|
||||
[ '', 'new title', 'new title' ],
|
||||
[ null, '', undefined ],
|
||||
[ null, null, undefined ],
|
||||
[ '', '', undefined ],
|
||||
[ undefined, undefined, undefined ],
|
||||
[ 'old title', null, null ],
|
||||
[ 'old title', undefined, null ],
|
||||
[ 'old title', '', null ],
|
||||
[null, 'new title', 'new title'],
|
||||
[undefined, 'new title', 'new title'],
|
||||
['', 'new title', 'new title'],
|
||||
[null, '', undefined],
|
||||
[null, null, undefined],
|
||||
['', '', undefined],
|
||||
[undefined, undefined, undefined],
|
||||
['old title', null, null],
|
||||
['old title', undefined, null],
|
||||
['old title', '', null],
|
||||
])('sends expected title based on original and new values', (originalTitle, newTitle, expectedSentTitle) => {
|
||||
const wrapper = createWrapper(Mock.of<ReachableServer>({ version: '2.6.0' }), 'create', originalTitle);
|
||||
|
||||
|
||||
@@ -53,10 +53,10 @@ describe('<ShortUrlsFilteringBar />', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[ 'tags=foo,bar,baz', 3 ],
|
||||
[ 'tags=foo,baz', 2 ],
|
||||
[ '', 0 ],
|
||||
[ 'foo=bar', 0 ],
|
||||
['tags=foo,bar,baz', 3],
|
||||
['tags=foo,baz', 2],
|
||||
['', 0],
|
||||
['foo=bar', 0],
|
||||
])('renders the proper amount of tags', (search, expectedTagComps) => {
|
||||
const wrapper = createWrapper(search);
|
||||
|
||||
@@ -82,8 +82,8 @@ describe('<ShortUrlsFilteringBar />', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[{ startDate: now }, `startDate=${encodeURIComponent(formatISO(now))}` ],
|
||||
[{ endDate: now }, `endDate=${encodeURIComponent(formatISO(now))}` ],
|
||||
[{ startDate: now }, `startDate=${encodeURIComponent(formatISO(now))}`],
|
||||
[{ endDate: now }, `endDate=${encodeURIComponent(formatISO(now))}`],
|
||||
[
|
||||
{ startDate: now, endDate: now },
|
||||
`startDate=${encodeURIComponent(formatISO(now))}&endDate=${encodeURIComponent(formatISO(now))}`,
|
||||
@@ -98,12 +98,12 @@ describe('<ShortUrlsFilteringBar />', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[ 'tags=foo,bar,baz', Mock.of<ReachableServer>({ version: '3.0.0' }), 1 ],
|
||||
[ 'tags=foo,bar', Mock.of<ReachableServer>({ version: '3.1.0' }), 1 ],
|
||||
[ 'tags=foo', Mock.of<ReachableServer>({ version: '3.0.0' }), 0 ],
|
||||
[ '', Mock.of<ReachableServer>({ version: '3.0.0' }), 0 ],
|
||||
[ 'tags=foo,bar,baz', Mock.of<ReachableServer>({ version: '2.10.0' }), 0 ],
|
||||
[ '', Mock.of<ReachableServer>({ version: '2.10.0' }), 0 ],
|
||||
['tags=foo,bar,baz', Mock.of<ReachableServer>({ version: '3.0.0' }), 1],
|
||||
['tags=foo,bar', Mock.of<ReachableServer>({ version: '3.1.0' }), 1],
|
||||
['tags=foo', Mock.of<ReachableServer>({ version: '3.0.0' }), 0],
|
||||
['', Mock.of<ReachableServer>({ version: '3.0.0' }), 0],
|
||||
['tags=foo,bar,baz', Mock.of<ReachableServer>({ version: '2.10.0' }), 0],
|
||||
['', Mock.of<ReachableServer>({ version: '2.10.0' }), 0],
|
||||
])(
|
||||
'renders tags mode toggle if the server supports it and there is more than one tag selected',
|
||||
(search, selectedServer, expectedTagToggleComponents) => {
|
||||
@@ -115,9 +115,9 @@ describe('<ShortUrlsFilteringBar />', () => {
|
||||
);
|
||||
|
||||
it.each([
|
||||
[ '', 'Short URLs including any tag.', false ],
|
||||
[ '&tagsMode=all', 'Short URLs including all tags.', true ],
|
||||
[ '&tagsMode=any', 'Short URLs including any tag.', false ],
|
||||
['', 'Short URLs including any tag.', false],
|
||||
['&tagsMode=all', 'Short URLs including all tags.', true],
|
||||
['&tagsMode=any', 'Short URLs including any tag.', false],
|
||||
])('expected tags mode tooltip title', (initialTagsMode, expectedToggleText, expectedChecked) => {
|
||||
const wrapper = createWrapper(`tags=foo,bar${initialTagsMode}`, Mock.of<ReachableServer>({ version: '3.0.0' }));
|
||||
const toggle = wrapper.find(TooltipToggleSwitch);
|
||||
@@ -127,9 +127,9 @@ describe('<ShortUrlsFilteringBar />', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[ '', 'tagsMode=all' ],
|
||||
[ '&tagsMode=all', 'tagsMode=any' ],
|
||||
[ '&tagsMode=any', 'tagsMode=all' ],
|
||||
['', 'tagsMode=all'],
|
||||
['&tagsMode=all', 'tagsMode=any'],
|
||||
['&tagsMode=any', 'tagsMode=all'],
|
||||
])('redirects to first page when tags mode changes', (initialTagsMode, expectedRedirectTagsMode) => {
|
||||
const wrapper = createWrapper(`tags=foo,bar${initialTagsMode}`, Mock.of<ReachableServer>({ version: '3.0.0' }));
|
||||
const toggle = wrapper.find(TooltipToggleSwitch);
|
||||
|
||||
@@ -30,7 +30,7 @@ describe('<ShortUrlsList />', () => {
|
||||
shortCode: 'testShortCode',
|
||||
shortUrl: 'https://www.example.com/testShortUrl',
|
||||
longUrl: 'https://www.example.com/testLongUrl',
|
||||
tags: [ 'test tag' ],
|
||||
tags: ['test tag'],
|
||||
}),
|
||||
],
|
||||
pagination: {},
|
||||
@@ -106,9 +106,9 @@ describe('<ShortUrlsList />', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[ Mock.of<ShortUrlsOrder>({ field: 'visits', dir: 'ASC' }), 'visits', 'ASC' ],
|
||||
[ Mock.of<ShortUrlsOrder>({ field: 'title', dir: 'DESC' }), 'title', 'DESC' ],
|
||||
[ Mock.of<ShortUrlsOrder>(), undefined, undefined ],
|
||||
[Mock.of<ShortUrlsOrder>({ field: 'visits', dir: 'ASC' }), 'visits', 'ASC'],
|
||||
[Mock.of<ShortUrlsOrder>({ field: 'title', dir: 'DESC' }), 'title', 'DESC'],
|
||||
[Mock.of<ShortUrlsOrder>(), undefined, undefined],
|
||||
])('has expected initial ordering', (initialOrderBy, field, dir) => {
|
||||
const wrapper = createWrapper(initialOrderBy);
|
||||
|
||||
|
||||
@@ -62,10 +62,10 @@ describe('<ShortUrlsTable />', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[ '2.6.0' as SemVer ],
|
||||
[ '2.6.1' as SemVer ],
|
||||
[ '2.7.0' as SemVer ],
|
||||
[ '3.0.0' as SemVer ],
|
||||
['2.6.0' as SemVer],
|
||||
['2.6.1' as SemVer],
|
||||
['2.7.0' as SemVer],
|
||||
['3.0.0' as SemVer],
|
||||
])('should render composed column when server supports title', (version) => {
|
||||
const wrapper = createWrapper(Mock.of<ReachableServer>({ version }));
|
||||
const composedColumn = wrapper.find('table').find('th').at(2);
|
||||
|
||||
@@ -10,7 +10,7 @@ import { Result } from '../../../src/utils/Result';
|
||||
describe('<CreateShortUrlResult />', () => {
|
||||
let wrapper: ShallowWrapper;
|
||||
const copyToClipboard = jest.fn();
|
||||
const useStateFlagTimeout = jest.fn(() => [ false, copyToClipboard ]) as StateFlagTimeout;
|
||||
const useStateFlagTimeout = jest.fn(() => [false, copyToClipboard]) as StateFlagTimeout;
|
||||
const CreateShortUrlResult = createCreateShortUrlResult(useStateFlagTimeout);
|
||||
const createWrapper = (result: ShortUrl | null = null, error = false) => {
|
||||
wrapper = shallow(
|
||||
|
||||
@@ -30,9 +30,9 @@ describe('<ExportShortUrlsBtn />', () => {
|
||||
afterEach(() => wrapper?.unmount());
|
||||
|
||||
it.each([
|
||||
[ undefined, 0 ],
|
||||
[ 1, 1 ],
|
||||
[ 4578, 4578 ],
|
||||
[undefined, 0],
|
||||
[1, 1],
|
||||
[4578, 4578],
|
||||
])('renders expected amount', (amount, expectedAmount) => {
|
||||
const wrapper = createWrapper(amount);
|
||||
|
||||
@@ -40,8 +40,8 @@ describe('<ExportShortUrlsBtn />', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[ null ],
|
||||
[ Mock.of<NotFoundServer>() ],
|
||||
[null],
|
||||
[Mock.of<NotFoundServer>()],
|
||||
])('does nothing on click if selected server is not reachable', (selectedServer) => {
|
||||
const wrapper = createWrapper(0, selectedServer);
|
||||
|
||||
@@ -51,12 +51,12 @@ describe('<ExportShortUrlsBtn />', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[ 10, 1 ],
|
||||
[ 30, 2 ],
|
||||
[ 39, 2 ],
|
||||
[ 40, 2 ],
|
||||
[ 41, 3 ],
|
||||
[ 385, 20 ],
|
||||
[10, 1],
|
||||
[30, 2],
|
||||
[39, 2],
|
||||
[40, 2],
|
||||
[41, 3],
|
||||
[385, 20],
|
||||
])('loads proper amount of pages based on the amount of results', async (amount, expectedPageLoads) => {
|
||||
const wrapper = createWrapper(amount, Mock.of<ReachableServer>({ id: '123' }));
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ describe('<QrCodeModal />', () => {
|
||||
wrapper = shallow(
|
||||
<QrCodeModal
|
||||
shortUrl={Mock.of<ShortUrl>({ shortUrl })}
|
||||
isOpen={true}
|
||||
isOpen
|
||||
toggle={() => {}}
|
||||
selectedServer={selectedServer}
|
||||
/>,
|
||||
@@ -43,10 +43,10 @@ describe('<QrCodeModal />', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[ '2.5.0' as SemVer, 0, '/qr-code?size=300&format=png' ],
|
||||
[ '2.6.0' as SemVer, 0, '/qr-code?size=300&format=png' ],
|
||||
[ '2.6.0' as SemVer, 10, '/qr-code?size=300&format=png&margin=10' ],
|
||||
[ '2.8.0' as SemVer, 0, '/qr-code?size=300&format=png&errorCorrection=L' ],
|
||||
['2.5.0' as SemVer, 0, '/qr-code?size=300&format=png'],
|
||||
['2.6.0' as SemVer, 0, '/qr-code?size=300&format=png'],
|
||||
['2.6.0' as SemVer, 10, '/qr-code?size=300&format=png&margin=10'],
|
||||
['2.8.0' as SemVer, 0, '/qr-code?size=300&format=png&errorCorrection=L'],
|
||||
])('displays an image with the QR code of the URL', (version, margin, expectedUrl) => {
|
||||
const wrapper = createWrapper(version);
|
||||
const formControls = wrapper.find('.form-control-range');
|
||||
@@ -66,12 +66,12 @@ describe('<QrCodeModal />', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[ 530, 0, 'lg' ],
|
||||
[ 200, 0, undefined ],
|
||||
[ 830, 0, 'xl' ],
|
||||
[ 430, 80, 'lg' ],
|
||||
[ 200, 50, undefined ],
|
||||
[ 720, 100, 'xl' ],
|
||||
[530, 0, 'lg'],
|
||||
[200, 0, undefined],
|
||||
[830, 0, 'xl'],
|
||||
[430, 80, 'lg'],
|
||||
[200, 50, undefined],
|
||||
[720, 100, 'xl'],
|
||||
])('renders expected size', (size, margin, modalSize) => {
|
||||
const wrapper = createWrapper();
|
||||
const formControls = wrapper.find('.form-control-range');
|
||||
@@ -87,8 +87,8 @@ describe('<QrCodeModal />', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[ '2.6.0' as SemVer, 1, 'col-md-4' ],
|
||||
[ '2.8.0' as SemVer, 2, 'col-md-6' ],
|
||||
['2.6.0' as SemVer, 1, 'col-md-4'],
|
||||
['2.8.0' as SemVer, 2, 'col-md-6'],
|
||||
])('shows expected components based on server version', (version, expectedAmountOfDropdowns, expectedRangeClass) => {
|
||||
const wrapper = createWrapper(version);
|
||||
const dropdownsLength = wrapper.find(QrFormatDropdown).length + wrapper.find(QrErrorCorrectionDropdown).length;
|
||||
|
||||
@@ -11,13 +11,13 @@ describe('<ShortUrlDetailLink />', () => {
|
||||
afterEach(() => wrapper?.unmount());
|
||||
|
||||
it.each([
|
||||
[ undefined, undefined ],
|
||||
[ null, null ],
|
||||
[ Mock.of<ReachableServer>({ id: '1' }), null ],
|
||||
[ Mock.of<ReachableServer>({ id: '1' }), undefined ],
|
||||
[ Mock.of<NotFoundServer>(), Mock.all<ShortUrl>() ],
|
||||
[ null, Mock.all<ShortUrl>() ],
|
||||
[ undefined, Mock.all<ShortUrl>() ],
|
||||
[undefined, undefined],
|
||||
[null, null],
|
||||
[Mock.of<ReachableServer>({ id: '1' }), null],
|
||||
[Mock.of<ReachableServer>({ id: '1' }), undefined],
|
||||
[Mock.of<NotFoundServer>(), Mock.all<ShortUrl>()],
|
||||
[null, Mock.all<ShortUrl>()],
|
||||
[undefined, Mock.all<ShortUrl>()],
|
||||
])('only renders a plain span when either server or short URL are not set', (selectedServer, shortUrl) => {
|
||||
wrapper = shallow(
|
||||
<ShortUrlDetailLink selectedServer={selectedServer} shortUrl={shortUrl} suffix="visits">
|
||||
|
||||
@@ -5,8 +5,8 @@ import { InfoTooltip } from '../../../src/utils/InfoTooltip';
|
||||
|
||||
describe('<ShortUrlFormCheckboxGroup />', () => {
|
||||
it.each([
|
||||
[ undefined, '', 0 ],
|
||||
[ 'This is the tooltip', 'me-2', 1 ],
|
||||
[undefined, '', 0],
|
||||
['This is the tooltip', 'me-2', 1],
|
||||
])('renders tooltip only when provided', (infoTooltip, expectedClassName, expectedAmountOfTooltips) => {
|
||||
const wrapper = shallow(<ShortUrlFormCheckboxGroup infoTooltip={infoTooltip} />);
|
||||
const checkbox = wrapper.find(Checkbox);
|
||||
|
||||
@@ -15,7 +15,7 @@ describe('<ShortUrlVisitsCount />', () => {
|
||||
|
||||
afterEach(() => wrapper?.unmount());
|
||||
|
||||
it.each([ undefined, {}])('just returns visits when no maxVisits is provided', (meta) => {
|
||||
it.each([undefined, {}])('just returns visits when no maxVisits is provided', (meta) => {
|
||||
const visitsCount = 45;
|
||||
const wrapper = createWrapper(visitsCount, Mock.of<ShortUrl>({ meta }));
|
||||
const maxVisitsHelper = wrapper.find('.short-urls-visits-count__max-visits-control');
|
||||
|
||||
@@ -18,7 +18,7 @@ describe('<ShortUrlsRow />', () => {
|
||||
const mockFunction = () => null;
|
||||
const ShortUrlsRowMenu = mockFunction;
|
||||
const stateFlagTimeout = jest.fn(() => true);
|
||||
const useStateFlagTimeout = jest.fn(() => [ false, stateFlagTimeout ]) as StateFlagTimeout;
|
||||
const useStateFlagTimeout = jest.fn(() => [false, stateFlagTimeout]) as StateFlagTimeout;
|
||||
const colorGenerator = Mock.of<ColorGenerator>({
|
||||
getColorForKey: jest.fn(),
|
||||
setColorForKey: jest.fn(),
|
||||
@@ -29,7 +29,7 @@ describe('<ShortUrlsRow />', () => {
|
||||
shortUrl: 'http://doma.in/abc123',
|
||||
longUrl: 'http://foo.com/bar',
|
||||
dateCreated: formatISO(parseDate('2018-05-23 18:30:41', 'yyyy-MM-dd HH:mm:ss')),
|
||||
tags: [ 'nodejs', 'reactjs' ],
|
||||
tags: ['nodejs', 'reactjs'],
|
||||
visitsCount: 45,
|
||||
domain: null,
|
||||
meta: {
|
||||
@@ -51,9 +51,9 @@ describe('<ShortUrlsRow />', () => {
|
||||
afterEach(() => wrapper.unmount());
|
||||
|
||||
it.each([
|
||||
[ null, 6 ],
|
||||
[ undefined, 6 ],
|
||||
[ 'The title', 7 ],
|
||||
[null, 6],
|
||||
[undefined, 6],
|
||||
['The title', 7],
|
||||
])('renders expected amount of columns', (title, expectedAmount) => {
|
||||
const wrapper = createWrapper(title);
|
||||
const cols = wrapper.find('td');
|
||||
|
||||
@@ -60,7 +60,7 @@ describe('shortUrlDeletionReducer', () => {
|
||||
});
|
||||
|
||||
it.each(
|
||||
[[ undefined ], [ null ], [ 'example.com' ]],
|
||||
[[undefined], [null], ['example.com']],
|
||||
)('dispatches proper actions if API client request succeeds', async (domain) => {
|
||||
const apiClientMock = Mock.of<ShlinkApiClient>({
|
||||
deleteShortUrl: jest.fn(() => ''),
|
||||
|
||||
@@ -62,8 +62,8 @@ describe('shortUrlDetailReducer', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[ undefined ],
|
||||
[ Mock.all<ShortUrlsList>() ],
|
||||
[undefined],
|
||||
[Mock.all<ShortUrlsList>()],
|
||||
[
|
||||
Mock.of<ShortUrlsList>({
|
||||
shortUrls: { data: [] },
|
||||
@@ -72,7 +72,7 @@ describe('shortUrlDetailReducer', () => {
|
||||
[
|
||||
Mock.of<ShortUrlsList>({
|
||||
shortUrls: {
|
||||
data: [ Mock.of<ShortUrl>({ shortCode: 'this_will_not_match' }) ],
|
||||
data: [Mock.of<ShortUrl>({ shortCode: 'this_will_not_match' })],
|
||||
},
|
||||
}),
|
||||
],
|
||||
@@ -96,7 +96,7 @@ describe('shortUrlDetailReducer', () => {
|
||||
dispatchMock,
|
||||
buildGetState(Mock.of<ShortUrlsList>({
|
||||
shortUrls: {
|
||||
data: [ foundShortUrl ],
|
||||
data: [foundShortUrl],
|
||||
},
|
||||
})),
|
||||
);
|
||||
|
||||
@@ -48,7 +48,7 @@ describe('shortUrlEditionReducer', () => {
|
||||
|
||||
afterEach(jest.clearAllMocks);
|
||||
|
||||
it.each([[ undefined ], [ null ], [ 'example.com' ]])('dispatches short URL on success', async (domain) => {
|
||||
it.each([[undefined], [null], ['example.com']])('dispatches short URL on success', async (domain) => {
|
||||
await editShortUrl(buildShlinkApiClient)(shortCode, domain, { longUrl })(dispatch, createGetState());
|
||||
|
||||
expect(buildShlinkApiClient).toHaveBeenCalledTimes(1);
|
||||
@@ -60,12 +60,12 @@ describe('shortUrlEditionReducer', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[ null, { tags: [ 'foo', 'bar' ] }, 1 ],
|
||||
[ null, {}, 0 ],
|
||||
[ Mock.of<ReachableServer>({ version: '2.6.0' }), {}, 0 ],
|
||||
[ Mock.of<ReachableServer>({ version: '2.6.0' }), { tags: [ 'foo', 'bar' ] }, 0 ],
|
||||
[ Mock.of<ReachableServer>({ version: '2.5.0' }), {}, 0 ],
|
||||
[ Mock.of<ReachableServer>({ version: '2.5.0' }), { tags: [ 'foo', 'bar' ] }, 1 ],
|
||||
[null, { tags: ['foo', 'bar'] }, 1],
|
||||
[null, {}, 0],
|
||||
[Mock.of<ReachableServer>({ version: '2.6.0' }), {}, 0],
|
||||
[Mock.of<ReachableServer>({ version: '2.6.0' }), { tags: ['foo', 'bar'] }, 0],
|
||||
[Mock.of<ReachableServer>({ version: '2.5.0' }), {}, 0],
|
||||
[Mock.of<ReachableServer>({ version: '2.5.0' }), { tags: ['foo', 'bar'] }, 1],
|
||||
])(
|
||||
'sends tags separately when appropriate, based on selected server and the payload',
|
||||
async (server, payload, expectedTagsCalls) => {
|
||||
|
||||
@@ -67,11 +67,11 @@ describe('shortUrlsListReducer', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[[ createNewShortUrlVisit(11) ], 11 ],
|
||||
[[ createNewShortUrlVisit(30) ], 30 ],
|
||||
[[ createNewShortUrlVisit(20), createNewShortUrlVisit(40) ], 40 ],
|
||||
[[{}], 10 ],
|
||||
[[], 10 ],
|
||||
[[createNewShortUrlVisit(11)], 11],
|
||||
[[createNewShortUrlVisit(30)], 30],
|
||||
[[createNewShortUrlVisit(20), createNewShortUrlVisit(40)], 40],
|
||||
[[{}], 10],
|
||||
[[], 10],
|
||||
])('updates visits count on CREATE_VISITS', (createdVisits, expectedCount) => {
|
||||
const state = {
|
||||
shortUrls: Mock.of<ShlinkShortUrlsResponse>({
|
||||
@@ -155,9 +155,9 @@ describe('shortUrlsListReducer', () => {
|
||||
it.each([
|
||||
((): [ShortUrl, ShortUrl[], ShortUrl[]] => {
|
||||
const editedShortUrl = Mock.of<ShortUrl>({ shortCode: 'notMatching' });
|
||||
const list = [ Mock.of<ShortUrl>({ shortCode: 'foo' }), Mock.of<ShortUrl>({ shortCode: 'bar' }) ];
|
||||
const list = [Mock.of<ShortUrl>({ shortCode: 'foo' }), Mock.of<ShortUrl>({ shortCode: 'bar' })];
|
||||
|
||||
return [ editedShortUrl, list, list ];
|
||||
return [editedShortUrl, list, list];
|
||||
})(),
|
||||
((): [ShortUrl, ShortUrl[], ShortUrl[]] => {
|
||||
const editedShortUrl = Mock.of<ShortUrl>({ shortCode: 'matching', longUrl: 'new_one' });
|
||||
@@ -165,9 +165,9 @@ describe('shortUrlsListReducer', () => {
|
||||
Mock.of<ShortUrl>({ shortCode: 'matching', longUrl: 'old_one' }),
|
||||
Mock.of<ShortUrl>({ shortCode: 'bar' }),
|
||||
];
|
||||
const expectedList = [ editedShortUrl, list[1] ];
|
||||
const expectedList = [editedShortUrl, list[1]];
|
||||
|
||||
return [ editedShortUrl, list, expectedList ];
|
||||
return [editedShortUrl, list, expectedList];
|
||||
})(),
|
||||
])('updates matching short URL on SHORT_URL_EDITED', (editedShortUrl, initialList, expectedList) => {
|
||||
const state = {
|
||||
|
||||
Reference in New Issue
Block a user