Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit 7eb1ec7

Browse files
committed
add tests for #376
1 parent 3f586e1 commit 7eb1ec7

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

test/app/src/routes/blog/_posts.js

+27
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,33 @@ const posts = [
9797
<p>Nellie is blowing them all AWAY. I will be a bigger and hairier mole than the one on your inner left thigh! I'll sacrifice anything for my children.</p>
9898
<p>Up yours, granny! You couldn't handle it! Hey, Dad. Look at you. You're a year older…and a year closer to death. Buster: Oh yeah, I guess that's kind of funny. Bob Loblaw Law Blog. The guy runs a prison, he can have any piece of ass he wants.</p>
9999
100+
<p><a href="blog/another-long-post">clicking this link should reset scroll</a></p>
101+
<p><a href="blog/another-long-post" sapper-noscroll>clicking this link should not affect scroll</a></p>
102+
103+
<h2 id='three'>Three</h2>
104+
<p>I prematurely shot my wad on what was supposed to be a dry run, so now I'm afraid I have something of a mess on my hands. Dead Dove DO NOT EAT. Never once touched my per diem. I'd go to Craft Service, get some raw veggies, bacon, Cup-A-Soup…baby, I got a stew goin'. You're losing blood, aren't you? Gob: Probably, my socks are wet. Sure, let the little fruit do it. HUZZAH! Although George Michael had only got to second base, he'd gone in head first, like Pete Rose. I will pack your sweet pink mouth with so much ice cream you'll be the envy of every Jerry and Jane on the block!</p>
105+
<p>Gosh Mom… after all these years, God's not going to take a call from you. Come on, this is a Bluth family celebration. It's no place for children.</p>
106+
<p>And I wouldn't just lie there, if that's what you're thinking. That's not what I WAS thinking. Who? i just dont want him to point out my cracker ass in front of ann. When a man needs to prove to a woman that he's actually… When a man loves a woman… Heyyyyyy Uncle Father Oscar. [Stabbing Gob] White power! Gob: I'm white! Let me take off my assistant's skirt and put on my Barbra-Streisand-in-The-Prince-of-Tides ass-masking therapist pantsuit. In the mid '90s, Tobias formed a folk music band with Lindsay and Maebe which he called Dr. Funke's 100 Percent Natural Good Time Family Band Solution. The group was underwritten by the Natural Food Life Company, a division of Chem-Grow, an Allen Crayne acqusition, which was part of the Squimm Group. Their motto was simple: We keep you alive.</p>
107+
108+
<h2 id='four'>Four</h2>
109+
<p>If you didn't have adult onset diabetes, I wouldn't mind giving you a little sugar. Everybody dance NOW. And the soup of the day is bread. Great, now I'm gonna smell to high heaven like a tuna melt!</p>
110+
<p>That's how Tony Wonder lost a nut. She calls it a Mayonegg. Go ahead, touch the Cornballer. There's a new daddy in town. A discipline daddy.</p>
111+
`
112+
},
113+
114+
{
115+
title: 'Another long post',
116+
slug: 'another-long-post',
117+
html: `
118+
<h2 id='one'>One</h2>
119+
<p>I'll have a vodka rocks. (Mom, it's breakfast time.) And a piece of toast. Let me out that Queen. Fried cheese… with club sauce.</p>
120+
<p>Her lawyers are claiming the seal is worth $250,000. And that's not even including Buster's Swatch. This was a big get for God. What, so the guy we are meeting with can't even grow his own hair? COME ON! She's always got to wedge herself in the middle of us so that she can control everything. Yeah. Mom's awesome. It's, like, Hey, you want to go down to the whirlpool? Yeah, I don't have a husband. I call it Swing City. The CIA should've just Googled for his hideout, evidently. There are dozens of us! DOZENS! Yeah, like I'm going to take a whiz through this $5,000 suit. COME ON.</p>
121+
122+
<h2 id='two'>Two</h2>
123+
<p>Tobias Fünke costume. Heart attack never stopped old big bear.</p>
124+
<p>Nellie is blowing them all AWAY. I will be a bigger and hairier mole than the one on your inner left thigh! I'll sacrifice anything for my children.</p>
125+
<p>Up yours, granny! You couldn't handle it! Hey, Dad. Look at you. You're a year older…and a year closer to death. Buster: Oh yeah, I guess that's kind of funny. Bob Loblaw Law Blog. The guy runs a prison, he can have any piece of ass he wants.</p>
126+
100127
<h2 id='three'>Three</h2>
101128
<p>I prematurely shot my wad on what was supposed to be a dry run, so now I'm afraid I have something of a mess on my hands. Dead Dove DO NOT EAT. Never once touched my per diem. I'd go to Craft Service, get some raw veggies, bacon, Cup-A-Soup…baby, I got a stew goin'. You're losing blood, aren't you? Gob: Probably, my socks are wet. Sure, let the little fruit do it. HUZZAH! Although George Michael had only got to second base, he'd gone in head first, like Pete Rose. I will pack your sweet pink mouth with so much ice cream you'll be the envy of every Jerry and Jane on the block!</p>
102129
<p>Gosh Mom… after all these years, God's not going to take a call from you. Come on, this is a Bluth family celebration. It's no place for children.</p>

test/common/test.js

+24
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,30 @@ function run({ mode, basepath = '' }) {
795795
assert.equal(title, 'encöded');
796796
});
797797
});
798+
799+
it('resets scroll when a link is clicked', () => {
800+
return nightmare.goto(`${base}/blog/a-very-long-post`)
801+
.init()
802+
.evaluate(() => window.scrollTo(0, 200))
803+
.click('[href="blog/another-long-post"]')
804+
.wait(100)
805+
.evaluate(() => window.scrollY)
806+
.then(scrollY => {
807+
assert.equal(scrollY, 0);
808+
});
809+
});
810+
811+
it('preserves scroll when a link with sapper-noscroll is clicked', () => {
812+
return nightmare.goto(`${base}/blog/a-very-long-post`)
813+
.init()
814+
.evaluate(() => window.scrollTo(0, 200))
815+
.click('[href="blog/another-long-post"][sapper-noscroll]')
816+
.wait(100)
817+
.evaluate(() => window.scrollY)
818+
.then(scrollY => {
819+
assert.equal(scrollY, 200);
820+
});
821+
});
798822
});
799823

800824
describe('headers', () => {

0 commit comments

Comments
 (0)