mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-11 10:03:51 +00:00
Enhanced ReportExporter test
This commit is contained in:
@@ -3,6 +3,7 @@ import { CsvJson } from 'csvjson';
|
||||
import { ReportExporter } from '../../../src/common/services/ReportExporter';
|
||||
import { NormalizedVisit } from '../../../src/visits/types';
|
||||
import { windowMock } from '../../mocks/WindowMock';
|
||||
import { ExportableShortUrl } from '../../../src/short-urls/data';
|
||||
|
||||
describe('ReportExporter', () => {
|
||||
const toCSV = jest.fn();
|
||||
@@ -44,4 +45,29 @@ describe('ReportExporter', () => {
|
||||
expect(toCSV).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('exportShortUrls', () => {
|
||||
it('parses provided short URLs to CSV', () => {
|
||||
const shortUrls: ExportableShortUrl[] = [
|
||||
{
|
||||
shortUrl: 'shortUrl',
|
||||
visits: 10,
|
||||
title: '',
|
||||
createdAt: '',
|
||||
longUrl: '',
|
||||
tags: '',
|
||||
},
|
||||
];
|
||||
|
||||
exporter.exportShortUrls(shortUrls);
|
||||
|
||||
expect(toCSV).toHaveBeenCalledWith(shortUrls, { headers: 'key', wrap: true });
|
||||
});
|
||||
|
||||
it('skips execution when list of visits is empty', () => {
|
||||
exporter.exportShortUrls([]);
|
||||
|
||||
expect(toCSV).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user