26 lines
772 B
TypeScript
26 lines
772 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import type { DownloadAdapter, TextDownload } from '../../src/exports/download-adapter';
|
|
import { downloadText } from '../../src/exports/text-download';
|
|
|
|
class MemoryDownloadAdapter implements DownloadAdapter {
|
|
artifacts: TextDownload[] = [];
|
|
|
|
download(artifact: TextDownload): void {
|
|
this.artifacts.push(artifact);
|
|
}
|
|
}
|
|
|
|
describe('download adapter', () => {
|
|
it('keeps export generation independent from browser download APIs', () => {
|
|
const downloads = new MemoryDownloadAdapter();
|
|
|
|
downloadText(downloads, 'findings.csv', 'Name;Severity', 'text/csv');
|
|
|
|
expect(downloads.artifacts).toEqual([{
|
|
fileName: 'findings.csv',
|
|
text: 'Name;Severity',
|
|
mediaType: 'text/csv'
|
|
}]);
|
|
});
|
|
});
|