Skip to content

Commit

Permalink
infra(tests): add test for links scrolled into viewport
Browse files Browse the repository at this point in the history
  • Loading branch information
addyosmani committed Dec 10, 2018
1 parent 972eacc commit 7b7e5ff
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/sample.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,27 @@ describe('quicklink tests', function () {
expect(responseURLs).to.include(`${server}/3.html`);
});

it('should prefetch in-viewport links that scroll into view correctly (UMD)', async function () {
const responseURLs = [];
page.on('response', resp => {
responseURLs.push(resp.url());
});
await page.goto(`${server}/test-basic-usage.html`);
await page.setViewport({
width: 1200,
height: 800,
});
await page.evaluate(_ => {
window.scrollBy(0, window.innerHeight);
});
await page.waitFor(1000);
expect(responseURLs).to.be.an('array');
expect(responseURLs).to.include(`${server}/1.html`);
expect(responseURLs).to.include(`${server}/2.html`);
expect(responseURLs).to.include(`${server}/3.html`);
expect(responseURLs).to.include(`${server}/4.html`);
});

it('should prefetch a static list of URLs correctly', async function () {
const responseURLs = [];
page.on('response', resp => {
Expand Down

0 comments on commit 7b7e5ff

Please sign in to comment.