add tests

This commit is contained in:
Conduitry
2019-06-11 11:32:00 -04:00
parent 57b11b4b67
commit c4f92a597d
4 changed files with 37 additions and 0 deletions

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

View File

@@ -27,6 +27,15 @@ describe('preloading', function() {
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 () => {
await r.load('/preload-nothing');