mirror of
https://github.com/foliojs/pdfkit.git
synced 2025-12-08 20:15:54 +00:00
* Handle null values in table text * Add test case for null value in table text * Update CHANGELOG.md
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, null, 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);
|
|
});
|
|
});
|
|
});
|