Skip to content

Commit

Permalink
add test for concurrent generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Grainger committed Sep 28, 2017
1 parent 797bdcb commit 61317c4
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,27 @@ describe('HtmlPdf', () => {

});

describe('Concurrent PDF generation', function() {
this.timeout(30000);
async function createAndParse(index) {
const html = `<p>${ index }</p>`;
const result = await HtmlPdf.create(html);
const parsed = await getParsedPdf(result.toBuffer());
const re = /^(\d+)\r\n----------------Page \(0\) Break----------------\r\n$/;
return (re.exec(parsed.getRawTextContent()) || [])[1];
}

const length = 15;
it(`should concurrently generate ${ length } PDFs`, async () => {
const input = Array.from({ length }, (v, i) => `${i}`);
const results = await Promise.all(input.map(createAndParse));
expect(results.length).to.be.equal(length);

// verify round trip.
expect(results).to.eql(input);
});
});

});

describe('CreateResult', () => {
Expand Down

0 comments on commit 61317c4

Please sign in to comment.