Skip to content

Commit

Permalink
Merge pull request #3 from mtlewis/bug/info-properties-never-set
Browse files Browse the repository at this point in the history
(bugfix) Fix setting of info properties on pdfs
  • Loading branch information
mtlewis authored Jul 30, 2018
2 parents c96b6a4 + 818ff11 commit e1db088
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 e1db088

Please sign in to comment.