add tests for #376

This commit is contained in:
Rich Harris
2018-10-05 20:59:45 -04:00
parent 3f586e19a1
commit 7eb1ec727c
2 changed files with 51 additions and 0 deletions

View File

@@ -795,6 +795,30 @@ function run({ mode, basepath = '' }) {
assert.equal(title, 'encöded');
});
});
it('resets scroll when a link is clicked', () => {
return nightmare.goto(`${base}/blog/a-very-long-post`)
.init()
.evaluate(() => window.scrollTo(0, 200))
.click('[href="blog/another-long-post"]')
.wait(100)
.evaluate(() => window.scrollY)
.then(scrollY => {
assert.equal(scrollY, 0);
});
});
it('preserves scroll when a link with sapper-noscroll is clicked', () => {
return nightmare.goto(`${base}/blog/a-very-long-post`)
.init()
.evaluate(() => window.scrollTo(0, 200))
.click('[href="blog/another-long-post"][sapper-noscroll]')
.wait(100)
.evaluate(() => window.scrollY)
.then(scrollY => {
assert.equal(scrollY, 200);
});
});
});
describe('headers', () => {