Speed up a link preview fetch test

This commit is contained in:
Evan Hahn 2021-07-07 19:11:44 -05:00 committed by GitHub
parent ff20c652d2
commit 7efa4f1a8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -844,8 +844,6 @@ describe('link preview fetching', () => {
}); });
it('stops reading bodies after 500 kilobytes', async function test() { it('stops reading bodies after 500 kilobytes', async function test() {
this.timeout(10000);
const shouldNeverBeCalled = sinon.stub(); const shouldNeverBeCalled = sinon.stub();
const fakeFetch = stub().resolves( const fakeFetch = stub().resolves(
@ -854,10 +852,9 @@ describe('link preview fetching', () => {
yield new TextEncoder().encode( yield new TextEncoder().encode(
'<!doctype html><head><title>foo bar</title>' '<!doctype html><head><title>foo bar</title>'
); );
const spaces = new Uint8Array(1024).fill(32); const spaces = new Uint8Array(250 * 1024).fill(32);
for (let i = 0; i < 500; i += 1) { yield spaces;
yield spaces; yield spaces;
}
shouldNeverBeCalled(); shouldNeverBeCalled();
yield new TextEncoder().encode( yield new TextEncoder().encode(
'<meta property="og:description" content="should be ignored">' '<meta property="og:description" content="should be ignored">'