From 11d3da3aed7cbb1a3c982025b35f744bbf2c105b Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Sat, 2 Feb 2019 15:42:35 -0500 Subject: [PATCH] add session tests --- test/apps/layout/src/client.js | 5 ----- test/apps/{store => session}/rollup.config.js | 0 test/apps/{store => session}/src/client.js | 0 .../{store => session}/src/routes/_error.html | 0 .../{store => session}/src/routes/index.html | 0 test/apps/session/src/routes/preloaded.html | 18 ++++++++++++++++ test/apps/session/src/routes/session.html | 10 +++++++++ test/apps/{store => session}/src/server.js | 0 .../{store => session}/src/service-worker.js | 0 .../apps/{store => session}/src/template.html | 0 test/apps/{store => session}/test.ts | 21 ++++++++++++++++--- test/apps/store/src/routes/store.html | 6 ------ 12 files changed, 46 insertions(+), 14 deletions(-) rename test/apps/{store => session}/rollup.config.js (100%) rename test/apps/{store => session}/src/client.js (100%) rename test/apps/{store => session}/src/routes/_error.html (100%) rename test/apps/{store => session}/src/routes/index.html (100%) create mode 100644 test/apps/session/src/routes/preloaded.html create mode 100644 test/apps/session/src/routes/session.html rename test/apps/{store => session}/src/server.js (100%) rename test/apps/{store => session}/src/service-worker.js (100%) rename test/apps/{store => session}/src/template.html (100%) rename test/apps/{store => session}/test.ts (59%) delete mode 100644 test/apps/store/src/routes/store.html diff --git a/test/apps/layout/src/client.js b/test/apps/layout/src/client.js index c492517..6cce7e6 100644 --- a/test/apps/layout/src/client.js +++ b/test/apps/layout/src/client.js @@ -2,11 +2,6 @@ import * as sapper from '@sapper/app'; window.start = () => sapper.start({ target: document.querySelector('#sapper') -}).catch(err => { - console.error(`OH NO! ${err.message}`); - throw err; -}).then(() => { - console.log(`STARTED`); }); window.prefetchRoutes = () => sapper.prefetchRoutes(); diff --git a/test/apps/store/rollup.config.js b/test/apps/session/rollup.config.js similarity index 100% rename from test/apps/store/rollup.config.js rename to test/apps/session/rollup.config.js diff --git a/test/apps/store/src/client.js b/test/apps/session/src/client.js similarity index 100% rename from test/apps/store/src/client.js rename to test/apps/session/src/client.js diff --git a/test/apps/store/src/routes/_error.html b/test/apps/session/src/routes/_error.html similarity index 100% rename from test/apps/store/src/routes/_error.html rename to test/apps/session/src/routes/_error.html diff --git a/test/apps/store/src/routes/index.html b/test/apps/session/src/routes/index.html similarity index 100% rename from test/apps/store/src/routes/index.html rename to test/apps/session/src/routes/index.html diff --git a/test/apps/session/src/routes/preloaded.html b/test/apps/session/src/routes/preloaded.html new file mode 100644 index 0000000..6964d98 --- /dev/null +++ b/test/apps/session/src/routes/preloaded.html @@ -0,0 +1,18 @@ + + + + +

{title}

+ + \ No newline at end of file diff --git a/test/apps/session/src/routes/session.html b/test/apps/session/src/routes/session.html new file mode 100644 index 0000000..6501114 --- /dev/null +++ b/test/apps/session/src/routes/session.html @@ -0,0 +1,10 @@ + + +

{$session.title}

+ + \ No newline at end of file diff --git a/test/apps/store/src/server.js b/test/apps/session/src/server.js similarity index 100% rename from test/apps/store/src/server.js rename to test/apps/session/src/server.js diff --git a/test/apps/store/src/service-worker.js b/test/apps/session/src/service-worker.js similarity index 100% rename from test/apps/store/src/service-worker.js rename to test/apps/session/src/service-worker.js diff --git a/test/apps/store/src/template.html b/test/apps/session/src/template.html similarity index 100% rename from test/apps/store/src/template.html rename to test/apps/session/src/template.html diff --git a/test/apps/store/test.ts b/test/apps/session/test.ts similarity index 59% rename from test/apps/store/test.ts rename to test/apps/session/test.ts index b2e8cfa..3fd910f 100644 --- a/test/apps/store/test.ts +++ b/test/apps/session/test.ts @@ -3,7 +3,7 @@ import * as puppeteer from 'puppeteer'; import { build } from '../../../api'; import { AppRunner } from '../AppRunner'; -describe('store', function() { +describe('session', function() { this.timeout(10000); let runner: AppRunner; @@ -24,12 +24,27 @@ describe('store', function() { after(() => runner.end()); - it('renders store props', async () => { - await page.goto(`${base}/store`); + it('renders session props', async () => { + await page.goto(`${base}/session`); assert.equal(await title(), 'hello world'); await start(); assert.equal(await title(), 'hello world'); + + await page.click('button'); + assert.equal(await title(), 'changed'); + }); + + it('preloads session props', async () => { + await page.goto(`${base}/preloaded`); + + assert.equal(await title(), 'hello world'); + + await start(); + assert.equal(await title(), 'hello world'); + + await page.click('button'); + assert.equal(await title(), 'changed'); }); }); \ No newline at end of file diff --git a/test/apps/store/src/routes/store.html b/test/apps/store/src/routes/store.html deleted file mode 100644 index fbd1f36..0000000 --- a/test/apps/store/src/routes/store.html +++ /dev/null @@ -1,6 +0,0 @@ - - -

{$session.title}

\ No newline at end of file