pdfkit/tests/unit/document.spec.js
2019-05-06 08:51:49 -05:00

37 lines
763 B
JavaScript

import PDFDocument from '../../lib/document';
describe('PDFDocument', () => {
describe('font option', () => {
let fontSpy;
beforeEach(() => {
fontSpy = jest.spyOn(PDFDocument.prototype, 'font').mockReturnThis();
});
afterEach(() => {
fontSpy.mockRestore();
});
test('not defined', () => {
new PDFDocument();
expect(fontSpy).toBeCalledWith('Helvetica');
});
test('a string value', () => {
new PDFDocument({ font: 'Roboto' });
expect(fontSpy).toBeCalledWith('Roboto');
});
test('a falsy value', () => {
new PDFDocument({ font: null });
new PDFDocument({ font: false });
new PDFDocument({ font: '' });
expect(fontSpy).not.toBeCalled();
});
});
});