mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-23 15:41:32 +00:00
add tests
This commit is contained in:
6
test/apps/basics/src/routes/host.svelte
Normal file
6
test/apps/basics/src/routes/host.svelte
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<script>
|
||||||
|
import { stores } from '@sapper/app';
|
||||||
|
const { page } = stores();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h1>{$page.host.replace(/:\d+$/, '')}</h1>
|
||||||
@@ -239,6 +239,15 @@ describe('basics', function() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can access host through page store', async () => {
|
||||||
|
await r.load('/host');
|
||||||
|
|
||||||
|
assert.equal(await r.text('h1'), 'localhost');
|
||||||
|
|
||||||
|
await r.sapper.start();
|
||||||
|
assert.equal(await r.text('h1'), 'localhost');
|
||||||
|
});
|
||||||
|
|
||||||
// skipped because Nightmare doesn't seem to focus the <a> correctly
|
// skipped because Nightmare doesn't seem to focus the <a> correctly
|
||||||
it('resets the active element after navigation', async () => {
|
it('resets the active element after navigation', async () => {
|
||||||
await r.load('/');
|
await r.load('/');
|
||||||
|
|||||||
13
test/apps/preloading/src/routes/preload-values/host.svelte
Normal file
13
test/apps/preloading/src/routes/preload-values/host.svelte
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<script context="module">
|
||||||
|
export function preload(page) {
|
||||||
|
return {
|
||||||
|
host: page.host
|
||||||
|
};
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export let host;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h1>{host.replace(/:\d+$/, '')}</h1>
|
||||||
@@ -27,6 +27,15 @@ describe('preloading', function() {
|
|||||||
assert.equal(await r.text('h1'), 'true');
|
assert.equal(await r.text('h1'), 'true');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('retrieves host from preload', async () => {
|
||||||
|
await r.load('/preload-values/host');
|
||||||
|
|
||||||
|
assert.equal(await r.text('h1'), 'localhost');
|
||||||
|
|
||||||
|
await r.sapper.start();
|
||||||
|
assert.equal(await r.text('h1'), 'localhost');
|
||||||
|
});
|
||||||
|
|
||||||
it('prevent crash if preload return nothing', async () => {
|
it('prevent crash if preload return nothing', async () => {
|
||||||
await r.load('/preload-nothing');
|
await r.load('/preload-nothing');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user