spread routes

This commit is contained in:
cudr
2019-03-11 17:37:20 +03:00
parent 7be7e1eb9f
commit 81f80e6215
6 changed files with 60 additions and 6 deletions

View File

@@ -0,0 +1,3 @@
export function get(req, res) {
res.end(req.params.rest.join(','));
}

View 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>

View 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>

View File

@@ -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'
);
});
});