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

Commit 567863b

Browse files
committed
Try not to clobber formatting
1 parent 0874397 commit 567863b

File tree

1 file changed

+117
-117
lines changed

1 file changed

+117
-117
lines changed

test/apps/scroll/test.ts

Lines changed: 117 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,133 +1,133 @@
11
import * as assert from 'assert';
2-
import {build} from '../../../api';
3-
import {AppRunner} from '../AppRunner';
4-
5-
describe('scroll', function () {
6-
this.timeout(10000);
7-
8-
let r: AppRunner;
9-
10-
// hooks
11-
before('build app', () => build({cwd: __dirname}));
12-
before('start runner', async () => {
13-
r = await new AppRunner().start(__dirname);
14-
});
15-
16-
after(() => r && r.end());
17-
18-
// tests
19-
it('scrolls to active deeplink', async () => {
20-
await r.load('/tall-page#foo');
21-
await r.sapper.start();
22-
23-
const scrollY = await r.page.evaluate(() => window.scrollY);
24-
assert.ok(scrollY > 0, String(scrollY));
25-
});
26-
27-
it('scrolls to any deeplink if it was already active', async () => {
28-
await r.load('/tall-page#foo');
29-
await r.sapper.start();
30-
31-
let scrollY = await r.page.evaluate(() => window.scrollY);
32-
assert.ok(scrollY > 0, String(scrollY));
33-
34-
scrollY = await r.page.evaluate(() => {
35-
window.scrollTo(0, 0)
36-
return window.scrollY
37-
});
38-
assert.ok(scrollY === 0, String(scrollY));
39-
40-
await r.page.click('[href="tall-page#foo"]');
41-
scrollY = await r.page.evaluate(() => window.scrollY);
42-
assert.ok(scrollY > 0, String(scrollY));
43-
});
44-
45-
it('resets scroll when a link is clicked', async () => {
46-
await r.load('/tall-page#foo');
47-
await r.sapper.start();
48-
await r.sapper.prefetchRoutes();
49-
50-
await r.page.click('[href="another-tall-page"]');
51-
await r.wait();
52-
53-
assert.equal(
54-
await r.page.evaluate(() => window.scrollY),
55-
0
56-
);
57-
});
58-
59-
it('preserves scroll when a link with sapper-noscroll is clicked', async () => {
60-
await r.load('/tall-page#foo');
61-
await r.sapper.start();
62-
await r.sapper.prefetchRoutes();
63-
64-
await r.page.click('[href="another-tall-page"][sapper-noscroll]');
65-
await r.wait();
66-
67-
const scrollY = await r.page.evaluate(() => window.scrollY);
68-
69-
assert.ok(scrollY > 0);
70-
});
71-
72-
it('scrolls into a deeplink on a new page', async () => {
73-
await r.load('/tall-page#foo');
74-
await r.sapper.start();
75-
await r.sapper.prefetchRoutes();
76-
77-
await r.page.click('[href="another-tall-page#bar"]');
78-
await r.wait();
79-
assert.equal(await r.text('h1'), 'Another tall page');
80-
const scrollY = await r.page.evaluate(() => window.scrollY);
81-
assert.ok(scrollY > 0);
82-
});
83-
84-
it('scrolls to a deeplink on a new page no matter the previous scroll position', async () => {
85-
await r.load('/a-third-tall-page#top');
86-
await r.sapper.start();
87-
await r.sapper.prefetchRoutes();
88-
89-
await r.page.click('a#top');
90-
await r.wait();
91-
const firstScrollY = await r.page.evaluate(() => window.scrollY);
92-
93-
await r.load('/a-third-tall-page#bottom');
94-
await r.sapper.start();
95-
await r.sapper.prefetchRoutes();
96-
97-
await r.page.click('a#bottom');
98-
await r.wait();
99-
const secondScrollY = await r.page.evaluate(() => window.scrollY);
100-
101-
assert.equal(firstScrollY, secondScrollY);
2+
import { build } from '../../../api';
3+
import { AppRunner } from '../AppRunner';
4+
5+
describe('scroll', function() {
6+
this.timeout(10000);
7+
8+
let r: AppRunner;
9+
10+
// hooks
11+
before('build app', () => build({ cwd: __dirname }));
12+
before('start runner', async () => {
13+
r = await new AppRunner().start(__dirname);
14+
});
15+
16+
after(() => r && r.end());
17+
18+
// tests
19+
it('scrolls to active deeplink', async () => {
20+
await r.load('/tall-page#foo');
21+
await r.sapper.start();
22+
23+
const scrollY = await r.page.evaluate(() => window.scrollY);
24+
assert.ok(scrollY > 0, String(scrollY));
25+
});
26+
27+
it('scrolls to any deeplink if it was already active', async () => {
28+
await r.load('/tall-page#foo');
29+
await r.sapper.start();
30+
31+
let scrollY = await r.page.evaluate(() => window.scrollY);
32+
assert.ok(scrollY > 0, String(scrollY));
33+
34+
scrollY = await r.page.evaluate(() => {
35+
window.scrollTo(0, 0)
36+
return window.scrollY
37+
});
38+
assert.ok(scrollY === 0, String(scrollY));
39+
40+
await r.page.click('[href="tall-page#foo"]');
41+
scrollY = await r.page.evaluate(() => window.scrollY);
42+
assert.ok(scrollY > 0, String(scrollY));
43+
});
44+
45+
it('resets scroll when a link is clicked', async () => {
46+
await r.load('/tall-page#foo');
47+
await r.sapper.start();
48+
await r.sapper.prefetchRoutes();
49+
50+
await r.page.click('[href="another-tall-page"]');
51+
await r.wait();
52+
53+
assert.equal(
54+
await r.page.evaluate(() => window.scrollY),
55+
0
56+
);
57+
});
58+
59+
it('preserves scroll when a link with sapper-noscroll is clicked', async () => {
60+
await r.load('/tall-page#foo');
61+
await r.sapper.start();
62+
await r.sapper.prefetchRoutes();
63+
64+
await r.page.click('[href="another-tall-page"][sapper-noscroll]');
65+
await r.wait();
66+
67+
const scrollY = await r.page.evaluate(() => window.scrollY);
68+
69+
assert.ok(scrollY > 0);
70+
});
71+
72+
it('scrolls into a deeplink on a new page', async () => {
73+
await r.load('/tall-page#foo');
74+
await r.sapper.start();
75+
await r.sapper.prefetchRoutes();
76+
77+
await r.page.click('[href="another-tall-page#bar"]');
78+
await r.wait();
79+
assert.equal(await r.text('h1'), 'Another tall page');
80+
const scrollY = await r.page.evaluate(() => window.scrollY);
81+
assert.ok(scrollY > 0);
82+
});
83+
84+
it('scrolls to a deeplink on a new page no matter the previous scroll position', async () => {
85+
await r.load('/a-third-tall-page#top');
86+
await r.sapper.start();
87+
await r.sapper.prefetchRoutes();
88+
89+
await r.page.click('a#top');
90+
await r.wait();
91+
const firstScrollY = await r.page.evaluate(() => window.scrollY);
92+
93+
await r.load('/a-third-tall-page#bottom');
94+
await r.sapper.start();
95+
await r.sapper.prefetchRoutes();
96+
97+
await r.page.click('a#bottom');
98+
await r.wait();
99+
const secondScrollY = await r.page.evaluate(() => window.scrollY);
100+
101+
assert.equal(firstScrollY, secondScrollY);
102102
});
103103

104104
it('scrolls to the top when navigating with goto', async () => {
105-
await r.load(`/search-form#search`);
106-
await r.sapper.start();
105+
await r.load(`/search-form#search`);
106+
await r.sapper.start();
107107

108-
let initialScrollY = await r.page.evaluate(() => window.scrollY);
109-
assert.ok(initialScrollY > 0, String(initialScrollY));
108+
let initialScrollY = await r.page.evaluate(() => window.scrollY);
109+
assert.ok(initialScrollY > 0, String(initialScrollY));
110110

111-
await r.page.click("button#scroll");
111+
await r.page.click(`button#scroll`);
112112

113-
let scrollY = await r.page.evaluate(() => window.scrollY);
114-
assert.ok(scrollY === 0, String(scrollY));
113+
let scrollY = await r.page.evaluate(() => window.scrollY);
114+
assert.ok(scrollY === 0, String(scrollY));
115115
});
116116

117117
it('preserves scroll when noscroll: true is passed to goto', async () => {
118-
await r.load(`/search-form#search`);
119-
await r.sapper.start();
118+
await r.load(`/search-form#search`);
119+
await r.sapper.start();
120120

121-
let initialScrollY = await r.page.evaluate(() => window.scrollY);
122-
assert.ok(initialScrollY > 0, String(initialScrollY));
121+
let initialScrollY = await r.page.evaluate(() => window.scrollY);
122+
assert.ok(initialScrollY > 0, String(initialScrollY));
123123

124-
await r.page.click("button#preserve");
124+
await r.page.click(`button#preserve`);
125125

126-
let scrollY = await r.page.evaluate(() => window.scrollY);
127-
assert.ok(scrollY === initialScrollY, String(scrollY));
126+
let scrollY = await r.page.evaluate(() => window.scrollY);
127+
assert.ok(scrollY === initialScrollY, String(scrollY));
128128
});
129129

130-
it('survives the tests with no server errors', () => {
131-
assert.deepEqual(r.errors, []);
132-
});
130+
it('survives the tests with no server errors', () => {
131+
assert.deepEqual(r.errors, []);
132+
});
133133
});

0 commit comments

Comments
 (0)