mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-15 20:34:44 +00:00
spread routes
This commit is contained in:
3
test/apps/basics/src/routes/[...rest]/deep.json.js
Normal file
3
test/apps/basics/src/routes/[...rest]/deep.json.js
Normal file
@@ -0,0 +1,3 @@
|
||||
export function get(req, res) {
|
||||
res.end(req.params.rest.join(','));
|
||||
}
|
||||
7
test/apps/basics/src/routes/[...rest]/deep.svelte
Normal file
7
test/apps/basics/src/routes/[...rest]/deep.svelte
Normal file
@@ -0,0 +1,7 @@
|
||||
<script>
|
||||
import { page } from '@sapper/app';
|
||||
</script>
|
||||
|
||||
<h1>{$page.params.rest.join(',')}</h1>
|
||||
|
||||
<a href="xyz/abc/qwe/deep.json">deep</a>
|
||||
7
test/apps/basics/src/routes/[...rest]/index.svelte
Normal file
7
test/apps/basics/src/routes/[...rest]/index.svelte
Normal file
@@ -0,0 +1,7 @@
|
||||
<script>
|
||||
import { page } from '@sapper/app';
|
||||
</script>
|
||||
|
||||
<h1>{$page.params.rest.join(',')}</h1>
|
||||
|
||||
<a href="xyz/abc/deep">deep</a>
|
||||
@@ -275,4 +275,22 @@ describe('basics', function() {
|
||||
await wait(50);
|
||||
assert.equal(await title(), 'bar');
|
||||
});
|
||||
});
|
||||
|
||||
it('navigates to ...rest', async () => {
|
||||
await page.goto(`${base}/abc/xyz`);
|
||||
await start();
|
||||
|
||||
assert.equal(await title(), 'abc,xyz');
|
||||
|
||||
await page.click('[href="xyz/abc/deep"]');
|
||||
await wait(50);
|
||||
assert.equal(await title(), 'xyz,abc');
|
||||
|
||||
await page.click(`[href="xyz/abc/qwe/deep.json"]`);
|
||||
await wait(50);
|
||||
assert.equal(
|
||||
await page.evaluate(() => document.body.textContent),
|
||||
'xyz,abc,qwe'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user