30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
import { expect, test } from '@playwright/test';
|
|
import {
|
|
clearPendingFiles,
|
|
queuePendingFiles,
|
|
takePendingFiles
|
|
} from '../../src/lib/pending-files';
|
|
|
|
const pdf = () => new File(['%PDF-1.7'], 'akte.pdf', { type: 'application/pdf' });
|
|
const zip = () => new File(['PK'], 'archiv.zip', { type: 'application/zip' });
|
|
|
|
test.beforeEach(() => clearPendingFiles());
|
|
|
|
test('a target only receives the files queued for it', () => {
|
|
queuePendingFiles([zip()], 'bea');
|
|
queuePendingFiles([pdf()], 'pagination');
|
|
|
|
const paginationFiles = takePendingFiles('pagination');
|
|
|
|
expect(paginationFiles.map((file) => file.name)).toEqual(['akte.pdf']);
|
|
// The beA handoff must survive a pagination visit instead of being dropped.
|
|
expect(takePendingFiles('bea').map((file) => file.name)).toEqual(['archiv.zip']);
|
|
});
|
|
|
|
test('taking a target clears only that target', () => {
|
|
queuePendingFiles([pdf(), pdf()], 'pagination');
|
|
|
|
expect(takePendingFiles('pagination')).toHaveLength(2);
|
|
expect(takePendingFiles('pagination')).toHaveLength(0);
|
|
});
|