Merge pull request #539 from cudr/nested-routes-navigate-fix

Fix nested routes navigates
This commit is contained in:
Rich Harris
2019-02-01 06:39:25 -05:00
committed by GitHub
6 changed files with 45 additions and 11 deletions

View File

@@ -1,4 +1,6 @@
<h1>Great success!</h1>
<a href="slow-preload">slow preload</a>
<a href="foo">foo</a>
<a href="foo">foo</a>
<a href="prefetch/qwe" rel=prefetch>prefetch qwe</a>
<a href="prefetch/xyz" rel=prefetch>prefetch xyz</a>

View File

@@ -0,0 +1 @@
<h1>{params.slug}</h1>

View File

@@ -0,0 +1 @@
<svelte:component this={child.component} {...child.props}/>

View File

@@ -0,0 +1 @@
<h1>prefetch</h1>

View File

@@ -83,4 +83,31 @@ describe('preloading', function() {
assert.equal(page.url(), `${base}/foo`);
assert.equal(await title(), 'foo');
});
});
it('navigates to prefetched urls', async () => {
await page.goto(base);
await start();
await prefetchRoutes();
await page.hover('a[href="prefetch/qwe"]');
await wait(100);
await page.hover('a[href="prefetch/xyz"]');
await wait(100);
await page.click('a[href="prefetch/qwe"]');
await wait(50);
assert.equal(
await title(),
'qwe'
);
await page.goto(`${base}/prefetch`);
await wait(50);
assert.equal(
await title(),
'prefetch'
);
});
});