mirror of
https://github.com/foliojs/pdfkit.git
synced 2025-12-08 20:15:54 +00:00
* Add page size utilities - Added page.contentWidth - Added page.contentHeight * Add table support - Tables support cell customization (including colors) - Tables also support rotatable text (with alignment support) - Tables have accessibility support * chore: fix code generation context - code generation now respects the current document positioning to allow use of page dependent operations * chore: remove comments from build * removed unnecessary config optimisations * Optimize table minification * Performance improvements to tables * Improve font handling in tables
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
import PDFDocument from '../../lib/document';
|
|
import PDFTable from '../../lib/table';
|
|
import { deepMerge } from '../../lib/table/utils';
|
|
|
|
describe('table', () => {
|
|
test('created', () => {
|
|
const document = new PDFDocument();
|
|
expect(document.table()).toBeInstanceOf(PDFTable);
|
|
expect(document.table({ data: [] })).toBe(document);
|
|
});
|
|
test('row', () => {
|
|
const document = new PDFDocument();
|
|
const table = document.table();
|
|
table.row(['A', 'B', 'C']);
|
|
expect(table._columnWidths.length).toBe(3);
|
|
});
|
|
});
|
|
|
|
describe('utils', () => {
|
|
describe('deepMerge', () => {
|
|
test.each([
|
|
[{ a: 'hello' }, { b: 'world' }, { a: 'hello', b: 'world' }],
|
|
[{ a: 'hello' }, { a: 'world' }, { a: 'world' }],
|
|
[{}, { a: 'hello' }, { a: 'hello' }],
|
|
[{ a: 'hello' }, undefined, { a: 'hello' }],
|
|
[undefined, undefined, undefined],
|
|
[1, 2, 1],
|
|
[1, {}, 1],
|
|
[{ a: 'hello' }, { a: {} }, { a: 'hello' }],
|
|
[{ a: { b: 'hello' } }, { a: { b: 'world' } }, { a: { b: 'world' } }],
|
|
])('%o -> %o', function () {
|
|
const opts = Array.from(arguments);
|
|
const expected = opts.splice(-1, 1)[0];
|
|
expect(deepMerge(...opts)).toEqual(expected);
|
|
});
|
|
});
|
|
});
|