diff --git a/test/apps/basics/src/routes/host.svelte b/test/apps/basics/src/routes/host.svelte new file mode 100644 index 0000000..91fb544 --- /dev/null +++ b/test/apps/basics/src/routes/host.svelte @@ -0,0 +1,6 @@ + + +

{$page.host.replace(/:\d+$/, '')}

diff --git a/test/apps/basics/test.ts b/test/apps/basics/test.ts index ba443fd..4d2cdc8 100644 --- a/test/apps/basics/test.ts +++ b/test/apps/basics/test.ts @@ -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 correctly it('resets the active element after navigation', async () => { await r.load('/'); diff --git a/test/apps/preloading/src/routes/preload-values/host.svelte b/test/apps/preloading/src/routes/preload-values/host.svelte new file mode 100644 index 0000000..03d83d7 --- /dev/null +++ b/test/apps/preloading/src/routes/preload-values/host.svelte @@ -0,0 +1,13 @@ + + + + +

{host.replace(/:\d+$/, '')}

\ No newline at end of file diff --git a/test/apps/preloading/test.ts b/test/apps/preloading/test.ts index f62db63..e22622f 100644 --- a/test/apps/preloading/test.ts +++ b/test/apps/preloading/test.ts @@ -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');