mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 09:30:31 +03:00
Enhanced ReportExporter test
This commit is contained in:
parent
92ddcad753
commit
e44520b2c2
3 changed files with 29 additions and 5 deletions
|
@ -28,6 +28,6 @@
|
||||||
.search-field__close {
|
.search-field__close {
|
||||||
@include vertical-align();
|
@include vertical-align();
|
||||||
|
|
||||||
right: 15px;
|
right: 10px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,13 +47,11 @@ const SearchField = ({ onChange, className, large = true, noBorder = false, init
|
||||||
/>
|
/>
|
||||||
<FontAwesomeIcon icon={searchIcon} className="search-field__icon" />
|
<FontAwesomeIcon icon={searchIcon} className="search-field__icon" />
|
||||||
<div
|
<div
|
||||||
className="close search-field__close"
|
className="close search-field__close btn-close"
|
||||||
hidden={searchTerm === ''}
|
hidden={searchTerm === ''}
|
||||||
id="search-field__close"
|
id="search-field__close"
|
||||||
onClick={() => searchTermChanged('', 0)}
|
onClick={() => searchTermChanged('', 0)}
|
||||||
>
|
/>
|
||||||
×
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { CsvJson } from 'csvjson';
|
||||||
import { ReportExporter } from '../../../src/common/services/ReportExporter';
|
import { ReportExporter } from '../../../src/common/services/ReportExporter';
|
||||||
import { NormalizedVisit } from '../../../src/visits/types';
|
import { NormalizedVisit } from '../../../src/visits/types';
|
||||||
import { windowMock } from '../../mocks/WindowMock';
|
import { windowMock } from '../../mocks/WindowMock';
|
||||||
|
import { ExportableShortUrl } from '../../../src/short-urls/data';
|
||||||
|
|
||||||
describe('ReportExporter', () => {
|
describe('ReportExporter', () => {
|
||||||
const toCSV = jest.fn();
|
const toCSV = jest.fn();
|
||||||
|
@ -44,4 +45,29 @@ describe('ReportExporter', () => {
|
||||||
expect(toCSV).not.toHaveBeenCalled();
|
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();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue