1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
| import { describe, expect, it } from 'vitest';
|
| import { buildListPrintDocument, getListPrintTotalPages, validateListPrintPageRange } from '../helpers/listPrint';
|
| describe('listPrint', () => {
| it('calculates at least one page', () => {
| expect(getListPrintTotalPages(0, 20)).toBe(1);
| expect(getListPrintTotalPages(46, 20)).toBe(3);
| });
|
| it('validates the selected page range', () => {
| expect(validateListPrintPageRange(1, 3, 3)).toBe('');
| expect(validateListPrintPageRange(0, 1, 3)).toContain('起始页');
| expect(validateListPrintPageRange(3, 2, 3)).toContain('结束页');
| expect(validateListPrintPageRange(1, 4, 3)).toContain('总页数 3');
| });
|
| it('builds escaped, paged print html', () => {
| const html = buildListPrintDocument({
| columns: [{ field: 'name', title: '样品名称' }],
| direction: 'landscape',
| pageSize: 20,
| pages: [{ pageNumber: 2, rows: [{ name: '<样品>' }] }],
| paperType: 'A3',
| title: '样品接收与检验台账',
| total: 46,
| });
|
| expect(html).toContain('@page { size: A3 landscape;');
| expect(html).toContain('第 2 页 / 共 3 页');
| expect(html).toContain('<样品>');
| expect(html).toContain('<td class="sequence-column">21</td>');
| });
| });
|
|