From b6bc90cea9d26266e355cb9d734e4dad153d3197 Mon Sep 17 00:00:00 2001 From: cudr Date: Wed, 26 Dec 2018 13:20:07 +0300 Subject: [PATCH] add test --- test/apps/preloading/src/routes/index.html | 4 ++- .../src/routes/prefetch/[slug]/index.html | 1 + .../src/routes/prefetch/_layout.html | 1 + .../preloading/src/routes/prefetch/index.html | 1 + test/apps/preloading/test.ts | 29 ++++++++++++++++++- 5 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 test/apps/preloading/src/routes/prefetch/[slug]/index.html create mode 100644 test/apps/preloading/src/routes/prefetch/_layout.html create mode 100644 test/apps/preloading/src/routes/prefetch/index.html diff --git a/test/apps/preloading/src/routes/index.html b/test/apps/preloading/src/routes/index.html index e269e81..c214f0c 100644 --- a/test/apps/preloading/src/routes/index.html +++ b/test/apps/preloading/src/routes/index.html @@ -1,4 +1,6 @@

Great success!

slow preload -foo \ No newline at end of file +foo +prefetch qwe +prefetch xyz diff --git a/test/apps/preloading/src/routes/prefetch/[slug]/index.html b/test/apps/preloading/src/routes/prefetch/[slug]/index.html new file mode 100644 index 0000000..d13188c --- /dev/null +++ b/test/apps/preloading/src/routes/prefetch/[slug]/index.html @@ -0,0 +1 @@ +

{params.slug}

diff --git a/test/apps/preloading/src/routes/prefetch/_layout.html b/test/apps/preloading/src/routes/prefetch/_layout.html new file mode 100644 index 0000000..f11eb2a --- /dev/null +++ b/test/apps/preloading/src/routes/prefetch/_layout.html @@ -0,0 +1 @@ + diff --git a/test/apps/preloading/src/routes/prefetch/index.html b/test/apps/preloading/src/routes/prefetch/index.html new file mode 100644 index 0000000..7771d91 --- /dev/null +++ b/test/apps/preloading/src/routes/prefetch/index.html @@ -0,0 +1 @@ +

prefetch

diff --git a/test/apps/preloading/test.ts b/test/apps/preloading/test.ts index dccd667..a38592d 100644 --- a/test/apps/preloading/test.ts +++ b/test/apps/preloading/test.ts @@ -83,4 +83,31 @@ describe('preloading', function() { assert.equal(page.url(), `${base}/foo`); assert.equal(await title(), 'foo'); }); -}); \ No newline at end of file + + it('navigates to prefetched urls', async () => { + await page.goto(base); + await start(); + await prefetchRoutes(); + + await page.hover('a[href="prefetch/qwe"]'); + await wait(100); + await page.hover('a[href="prefetch/xyz"]'); + await wait(100); + + await page.click('a[href="prefetch/qwe"]'); + await wait(50); + + assert.equal( + await title(), + 'qwe' + ); + + await page.goto(`${base}/prefetch`); + await wait(50); + + assert.equal( + await title(), + 'prefetch' + ); + }); +});