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
57 lines
1.5 KiB
JavaScript
57 lines
1.5 KiB
JavaScript
import { normalizeSides } from '../../lib/utils';
|
|
|
|
describe('normalizeSides', () => {
|
|
test.each([
|
|
[1, { top: 1, right: 1, bottom: 1, left: 1 }],
|
|
[[1, 2], { top: 1, right: 2, bottom: 1, left: 2 }],
|
|
[
|
|
{ vertical: 1, horizontal: 2 },
|
|
{ top: 1, right: 2, bottom: 1, left: 2 },
|
|
],
|
|
[[1, 2, 3, 4], { top: 1, right: 2, bottom: 3, left: 4 }],
|
|
[
|
|
{ top: 1, right: 2, bottom: 3, left: 4 },
|
|
{ top: 1, right: 2, bottom: 3, left: 4 },
|
|
],
|
|
[
|
|
{ a: 'hi' },
|
|
{ top: undefined, right: undefined, bottom: undefined, left: undefined },
|
|
],
|
|
[
|
|
{ vertical: 'hi' },
|
|
{ top: 'hi', right: undefined, bottom: 'hi', left: undefined },
|
|
],
|
|
[
|
|
{ top: undefined },
|
|
{ top: undefined, right: undefined, bottom: undefined, left: undefined },
|
|
],
|
|
[
|
|
null,
|
|
{ top: undefined, right: undefined, bottom: undefined, left: undefined },
|
|
],
|
|
[
|
|
undefined,
|
|
{ top: undefined, right: undefined, bottom: undefined, left: undefined },
|
|
],
|
|
[true, { top: true, right: true, bottom: true, left: true }],
|
|
[false, { top: false, right: false, bottom: false, left: false }],
|
|
])('%s -> %s', (size, expected) => {
|
|
expect(normalizeSides(size)).toEqual(expected);
|
|
});
|
|
|
|
test('with transformer', () => {
|
|
expect(
|
|
normalizeSides(
|
|
undefined,
|
|
{ top: '1', right: '2', bottom: '3', left: '4' },
|
|
Number,
|
|
),
|
|
).toEqual({
|
|
top: 1,
|
|
right: 2,
|
|
bottom: 3,
|
|
left: 4,
|
|
});
|
|
});
|
|
});
|