mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-12 02:23:49 +00:00
Refactor short URL export so that it is compatible with what Shlink expects
This commit is contained in:
@@ -3,6 +3,7 @@ import { fromPartial } from '@total-typescript/shoehorn';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import type { ReportExporter } from '../../../src/common/services/ReportExporter';
|
||||
import type { NotFoundServer, SelectedServer } from '../../../src/servers/data';
|
||||
import type { ShortUrl } from '../../../src/short-urls/data';
|
||||
import { ExportShortUrlsBtn as createExportShortUrlsBtn } from '../../../src/short-urls/helpers/ExportShortUrlsBtn';
|
||||
import { renderWithEvents } from '../../__helpers__/setUpTest';
|
||||
|
||||
@@ -56,4 +57,22 @@ describe('<ExportShortUrlsBtn />', () => {
|
||||
expect(listShortUrls).toHaveBeenCalledTimes(expectedPageLoads);
|
||||
expect(exportShortUrls).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('maps short URLs for exporting', async () => {
|
||||
listShortUrls.mockResolvedValue({
|
||||
data: [fromPartial<ShortUrl>({
|
||||
shortUrl: 'https://s.test/short-code',
|
||||
tags: [],
|
||||
})],
|
||||
});
|
||||
const { user } = setUp(undefined, fromPartial({ id: '123' }));
|
||||
|
||||
await user.click(screen.getByRole('button'));
|
||||
|
||||
expect(exportShortUrls).toHaveBeenCalledWith([expect.objectContaining({
|
||||
shortUrl: 'https://s.test/short-code',
|
||||
domain: 's.test',
|
||||
shortCode: 'short-code',
|
||||
})]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user