Skip to content

Commit

Permalink
tests for error redirections
Browse files Browse the repository at this point in the history
  • Loading branch information
bleucitron committed Aug 11, 2021
1 parent ad62940 commit 06e26a5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
11 changes: 11 additions & 0 deletions packages/kit/test/apps/basics/src/routes/redirect/__error.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script context="module">
/** @type {import('@sveltejs/kit').ErrorLoad} */
export async function load() {
return {
status: 307,
redirect: './c'
};
}
</script>

<h1>Redirecting error page</h1>
11 changes: 11 additions & 0 deletions packages/kit/test/apps/basics/src/routes/redirect/_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,15 @@ export default function (test, is_dev) {
'This is your custom error page saying: ""redirect" property returned from load() must be accompanied by a 3xx status code"'
);
});

test.only(
'redirect from error on missing page',
'/redirect',
async ({ base, page, clicknav }) => {
await clicknav('[href="/redirect/nowhere"]');

// assert.equal(await page.url(), `${base}/redirect/c`);
assert.equal(await page.textContent('h1'), 'c');
}
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
<a href="/redirect/loopy/b">b (loopy)</a>

<a href="/redirect/missing-status/a">a (missing-status)</a>
<a href="/redirect/missing-status/b">b (missing-status)</a>
<a href="/redirect/missing-status/b">b (missing-status)</a>

<a href="/redirect/nowhere">nowhere</a>

0 comments on commit 06e26a5

Please sign in to comment.