Move more components to shlink-web-component when applicable

This commit is contained in:
Alejandro Celaya
2023-07-29 10:43:15 +02:00
parent 275745fd3a
commit 8d24116859
94 changed files with 224 additions and 209 deletions

View File

@@ -1,7 +1,7 @@
import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import type { ShlinkApiErrorProps } from '../../src/api/ShlinkApiError';
import { ShlinkApiError } from '../../src/api/ShlinkApiError';
import type { ShlinkApiErrorProps } from '../../shlink-web-component/common/ShlinkApiError';
import { ShlinkApiError } from '../../shlink-web-component/common/ShlinkApiError';
import type { InvalidArgumentError, ProblemDetailsError } from '../../src/api/types/errors';
import { ErrorTypeV2, ErrorTypeV3 } from '../../src/api/types/errors';

View File

@@ -1,6 +1,6 @@
import { render, screen } from '@testing-library/react';
import { SimplePaginator } from '../../src/common/SimplePaginator';
import { ELLIPSIS } from '../../src/utils/helpers/pagination';
import { SimplePaginator } from '../../shlink-web-component/utils/components/SimplePaginator';
import { ELLIPSIS } from '../../shlink-web-component/utils/helpers/pagination';
describe('<SimplePaginator />', () => {
const setUp = (pagesCount: number, currentPage = 1) => render(

View File

@@ -64,15 +64,4 @@ describe('HttpClient', () => {
await expect(httpClient.fetchJson('')).rejects.toEqual(theError);
});
});
describe('fetchBlob', () => {
it('returns response as blob', async () => {
const theBlob = new Blob();
fetch.mockResolvedValue({ blob: () => theBlob });
const result = await httpClient.fetchBlob('');
expect(result).toEqual(theBlob);
});
});
});

View File

@@ -1,6 +1,6 @@
import { fromPartial } from '@total-typescript/shoehorn';
import { ImageDownloader } from '../../../shlink-web-component/utils/services/ImageDownloader';
import type { HttpClient } from '../../../src/common/services/HttpClient';
import { ImageDownloader } from '../../../src/common/services/ImageDownloader';
import { windowMock } from '../../__mocks__/Window.mock';
describe('ImageDownloader', () => {

View File

@@ -3,7 +3,7 @@ import { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter } from 'react-router-dom';
import type { MercureInfo } from '../../shlink-web-component/mercure/reducers/mercureInfo';
import { Overview as overviewCreator } from '../../shlink-web-component/overview/Overview';
import { prettify } from '../../src/utils/helpers/numbers';
import { prettify } from '../../shlink-web-component/utils/helpers/numbers';
import { renderWithEvents } from '../__helpers__/setUpTest';
describe('<Overview />', () => {

View File

@@ -2,8 +2,8 @@ import { render, screen } from '@testing-library/react';
import { fromPartial } from '@total-typescript/shoehorn';
import { MemoryRouter } from 'react-router-dom';
import { Paginator } from '../../shlink-web-component/short-urls/Paginator';
import { ELLIPSIS } from '../../shlink-web-component/utils/helpers/pagination';
import type { ShlinkPaginator } from '../../src/api/types';
import { ELLIPSIS } from '../../src/utils/helpers/pagination';
describe('<Paginator />', () => {
const buildPaginator = (pagesCount?: number) => fromPartial<ShlinkPaginator>({ pagesCount, currentPage: 1 });

View File

@@ -1,6 +1,6 @@
import { screen } from '@testing-library/react';
import { QrErrorCorrectionDropdown } from '../../../../shlink-web-component/short-urls/helpers/qr-codes/QrErrorCorrectionDropdown';
import type { QrErrorCorrection } from '../../../../src/utils/helpers/qrCodes';
import type { QrErrorCorrection } from '../../../../shlink-web-component/utils/helpers/qrCodes';
import { renderWithEvents } from '../../../__helpers__/setUpTest';
describe('<QrErrorCorrectionDropdown />', () => {

View File

@@ -1,6 +1,6 @@
import { screen } from '@testing-library/react';
import { QrFormatDropdown } from '../../../../shlink-web-component/short-urls/helpers/qr-codes/QrFormatDropdown';
import type { QrCodeFormat } from '../../../../src/utils/helpers/qrCodes';
import type { QrCodeFormat } from '../../../../shlink-web-component/utils/helpers/qrCodes';
import { renderWithEvents } from '../../../__helpers__/setUpTest';
describe('<QrFormatDropdown />', () => {

View File

@@ -1,4 +1,4 @@
import { CopyToClipboardIcon } from '../../src/utils/CopyToClipboardIcon';
import { CopyToClipboardIcon } from '../../shlink-web-component/utils/components/CopyToClipboardIcon';
import { renderWithEvents } from '../__helpers__/setUpTest';
describe('<CopyToClipboardIcon />', () => {

View File

@@ -1,5 +1,5 @@
import { render, screen } from '@testing-library/react';
import { ExportBtn } from '../../src/utils/ExportBtn';
import { ExportBtn } from '../../shlink-web-component/utils/components/ExportBtn';
describe('<ExportBtn />', () => {
const setUp = (amount?: number, loading = false) => render(<ExportBtn amount={amount} loading={loading} />);

View File

@@ -1,7 +1,7 @@
import type { Placement } from '@popperjs/core';
import { screen, waitFor } from '@testing-library/react';
import type { InfoTooltipProps } from '../../src/utils/InfoTooltip';
import { InfoTooltip } from '../../src/utils/InfoTooltip';
import type { InfoTooltipProps } from '../../shlink-web-component/utils/components/InfoTooltip';
import { InfoTooltip } from '../../shlink-web-component/utils/components/InfoTooltip';
import { renderWithEvents } from '../__helpers__/setUpTest';
describe('<InfoTooltip />', () => {

View File

@@ -1,5 +1,5 @@
import { screen } from '@testing-library/react';
import { PaginationDropdown } from '../../src/utils/PaginationDropdown';
import { PaginationDropdown } from '../../shlink-web-component/utils/components/PaginationDropdown';
import { renderWithEvents } from '../__helpers__/setUpTest';
describe('<PaginationDropdown />', () => {

View File

@@ -1,4 +1,4 @@
import { roundTen } from '../../../src/utils/helpers/numbers';
import { roundTen } from '../../../shlink-web-component/utils/helpers/numbers';
describe('numbers', () => {
describe('roundTen', () => {

View File

@@ -1,5 +1,5 @@
import type { QrCodeFormat, QrErrorCorrection } from '../../../src/utils/helpers/qrCodes';
import { buildQrCodeUrl } from '../../../src/utils/helpers/qrCodes';
import type { QrCodeFormat, QrErrorCorrection } from '../../../shlink-web-component/utils/helpers/qrCodes';
import { buildQrCodeUrl } from '../../../shlink-web-component/utils/helpers/qrCodes';
describe('qrCodes', () => {
describe('buildQrCodeUrl', () => {

View File

@@ -1,6 +1,6 @@
import { render } from '@testing-library/react';
import { TableOrderIcon } from '../../../shlink-web-component/utils/table/TableOrderIcon';
import type { OrderDir } from '../../../src/utils/helpers/ordering';
import { TableOrderIcon } from '../../../src/utils/table/TableOrderIcon';
describe('<TableOrderIcon />', () => {
const setUp = (field: string, currentDir?: OrderDir, className?: string) => render(

View File

@@ -1,5 +1,4 @@
import {
capitalize,
nonEmptyValueOrNull,
parseBooleanToString,
parseOptionalBooleanToString,
@@ -45,17 +44,6 @@ describe('utils', () => {
});
});
describe('capitalize', () => {
it.each([
['foo', 'Foo'],
['BAR', 'BAR'],
['bAZ', 'BAZ'],
['with spaces', 'With spaces'],
])('sets first letter in uppercase', (value, expectedResult) => {
expect(capitalize(value)).toEqual(expectedResult);
});
});
describe('parseBooleanToString', () => {
it.each([
[true, 'true'],