From 393734cf188cef099ff2f0d50cf60c2aa3744cf8 Mon Sep 17 00:00:00 2001 From: Jakub Valenta Date: Wed, 24 Mar 2021 15:57:36 +0100 Subject: [PATCH] tests/font.spec.js: Add EmbeddedFont.embed() test --- tests/unit/font.spec.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/unit/font.spec.js b/tests/unit/font.spec.js index 09bc5b2..f8cc94d 100644 --- a/tests/unit/font.spec.js +++ b/tests/unit/font.spec.js @@ -33,4 +33,23 @@ describe('EmbeddedFont', () => { expect(runSpy).toBeCalledTimes(4); }); + + describe('emebed', () => { + test('sets BaseName based on font id and postscript name', () => { + const document = new PDFDocument(); + const font = PDFFontFactory.open( + document, + 'tests/fonts/Roboto-Regular.ttf', + undefined, + 'F1099' + ); + const dictionary = { + end: () => {}, + }; + font.dictionary = dictionary; + font.embed(); + + expect(dictionary.data.BaseFont).toBe('A@IIZZ+Roboto-Regular'); + }); + }); });