Skip to content

Commit

Permalink
(bugfix) Fix setting of info properties on pdfs
Browse files Browse the repository at this point in the history
  • Loading branch information
mtlewis committed Jul 30, 2018
1 parent c96b6a4 commit 818ff11
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export function toPDFMake(tag) {

const info = pick(attributes, ['title', 'author', 'subject', 'keywords']);

if (info.length > 0) {
if (Object.keys(info).length > 0) {
result.info = info;
}

Expand Down
12 changes: 11 additions & 1 deletion src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,17 @@ describe('#jsx-pdf', () => {
});
});

it('should error if a top level element appears below the top level', () => {
['title', 'author', 'subject', 'keywords'].forEach(field => {
it(`should set ${field} in info`, () => {
expect(toPDFMake(<document {...{ [field]: 'foo' }} />)).toEqual({
info: {
[field]: 'foo',
},
});
});
});

it('should error if a top-level element appears below the top level', () => {
expect(() => {
toPDFMake(
<document>
Expand Down

0 comments on commit 818ff11

Please sign in to comment.