mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-04-19 04:56:17 +00:00
Use external shlink-web-component and remove local one
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
import type { ShlinkDomain, ShlinkShortUrl, ShlinkVisits, ShlinkVisitsOverview } from '@shlinkio/shlink-web-component/api-contract';
|
||||
import type {
|
||||
ShlinkDomain,
|
||||
ShlinkShortUrl,
|
||||
ShlinkShortUrlsOrder,
|
||||
ShlinkVisits,
|
||||
ShlinkVisitsOverview,
|
||||
} from '@shlinkio/shlink-web-component/api-contract';
|
||||
import { ErrorTypeV2, ErrorTypeV3 } from '@shlinkio/shlink-web-component/api-contract';
|
||||
import { fromPartial } from '@total-typescript/shoehorn';
|
||||
import type { ShortUrlsOrder } from '../../../shlink-web-component/src/short-urls/data';
|
||||
import { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient';
|
||||
import type { HttpClient } from '../../../src/common/services/HttpClient';
|
||||
import type { OptionalString } from '../../../src/utils/utils';
|
||||
@@ -30,9 +35,9 @@ describe('ShlinkApiClient', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
[{ field: 'visits', dir: 'DESC' } as ShortUrlsOrder, '?orderBy=visits-DESC'],
|
||||
[{ field: 'longUrl', dir: 'ASC' } as ShortUrlsOrder, '?orderBy=longUrl-ASC'],
|
||||
[{ field: 'longUrl', dir: undefined } as ShortUrlsOrder, ''],
|
||||
[{ field: 'visits', dir: 'DESC' } as ShlinkShortUrlsOrder, '?orderBy=visits-DESC'],
|
||||
[{ field: 'longUrl', dir: 'ASC' } as ShlinkShortUrlsOrder, '?orderBy=longUrl-ASC'],
|
||||
[{ field: 'longUrl', dir: undefined } as ShlinkShortUrlsOrder, ''],
|
||||
])('parses orderBy in params', async (orderBy, expectedOrderBy) => {
|
||||
fetchJson.mockResolvedValue({ data: expectedList });
|
||||
const { listShortUrls } = buildApiClient();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { ShortUrlsListSettings as ShortUrlsSettings } from '@shlinkio/shlink-web-component';
|
||||
import { screen } from '@testing-library/react';
|
||||
import { fromPartial } from '@total-typescript/shoehorn';
|
||||
import type { ShortUrlsOrder } from '../../shlink-web-component/src/short-urls/data';
|
||||
import { ShortUrlsListSettings } from '../../src/settings/ShortUrlsListSettings';
|
||||
import { renderWithEvents } from '../__helpers__/setUpTest';
|
||||
|
||||
@@ -13,10 +12,10 @@ describe('<ShortUrlsListSettings />', () => {
|
||||
|
||||
it.each([
|
||||
[undefined, 'Order by: Created at - DESC'],
|
||||
[{}, 'Order by: Created at - DESC'],
|
||||
[{ defaultOrdering: {} }, 'Order by...'],
|
||||
[{ defaultOrdering: { field: 'longUrl', dir: 'DESC' } as ShortUrlsOrder }, 'Order by: Long URL - DESC'],
|
||||
[{ defaultOrdering: { field: 'visits', dir: 'ASC' } as ShortUrlsOrder }, 'Order by: Visits - ASC'],
|
||||
[fromPartial<ShortUrlsSettings>({}), 'Order by: Created at - DESC'],
|
||||
[fromPartial<ShortUrlsSettings>({ defaultOrdering: {} }), 'Order by...'],
|
||||
[fromPartial<ShortUrlsSettings>({ defaultOrdering: { field: 'longUrl', dir: 'DESC' } }), 'Order by: Long URL - DESC'],
|
||||
[fromPartial<ShortUrlsSettings>({ defaultOrdering: { field: 'visits', dir: 'ASC' } }), 'Order by: Visits - ASC'],
|
||||
])('shows expected ordering', (shortUrlsList, expectedOrder) => {
|
||||
setUp(shortUrlsList);
|
||||
expect(screen.getByRole('button')).toHaveTextContent(expectedOrder);
|
||||
|
||||
Reference in New Issue
Block a user