Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions backend/__tests__/unit/services/htmlToText.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ describe('htmlToText on hostile input', () => {
['"<!--" with no "-->"', '<!--'],
['"<p" with no ">"', '<p'],
['"&#" fragments', '&#'],
])('1 MB of %s reduces in well under a second', (_name, unit) => {
])('1 MB of %s reduces within five seconds', (_name, unit) => {
const input = unit.repeat(Math.ceil(MB / unit.length)).slice(0, MB);
const started = process.hrtime.bigint();
htmlToText(input);
const elapsedMs = Number(process.hrtime.bigint() - started) / 1e6;
expect(elapsedMs).toBeLessThan(1000);
});
// Leave runner scheduling headroom while still catching the old quadratic
// scan, which took roughly two minutes for a full-size fetched page.
expect(elapsedMs).toBeLessThan(5000);
}, 10000);
});

describe('decodeEntities', () => {
Expand Down
Loading