From c4f92a597d0d7d909f1461f98753a4ba77ace88b Mon Sep 17 00:00:00 2001 From: Conduitry Date: Tue, 11 Jun 2019 11:32:00 -0400 Subject: [PATCH] add tests --- test/apps/basics/src/routes/host.svelte | 6 ++++++ test/apps/basics/test.ts | 9 +++++++++ .../src/routes/preload-values/host.svelte | 13 +++++++++++++ test/apps/preloading/test.ts | 9 +++++++++ 4 files changed, 37 insertions(+) create mode 100644 test/apps/basics/src/routes/host.svelte create mode 100644 test/apps/preloading/src/routes/preload-values/host.svelte 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');