mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-15 03:53:51 +00:00
Updated to airbnb coding styles
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user