Skip to content

Commit

Permalink
failing test for #6337
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Sep 4, 2022
1 parent 5e0cfcb commit 1d4e69a
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/kit/test/apps/basics/src/routes/load/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<a href="/load/fetch-request">fetch request</a>
<a href="/load/fetch-relative">fetch relative</a>
<a href="/load/fetch-layout-relative/a/b/c">fetch layout relative</a>
<a href="/load/fetch-credentialed">fetch credentialed</a>
<a href="/load/fetch-headers">fetch headers</a>
<a href="/load/large-response">large response</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('./$types').LayoutLoad} */
export async function load({ fetch }) {
const res = await fetch('./data.json');
return await res.json();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<slot />
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<script>
/** @type {import('./$types').PageData} */
export let data;
</script>

<h1>the answer is {data.answer}</h1>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { json } from '@sveltejs/kit';

/** @type {import('./$types').RequestHandler} */
export function GET() {
return json({ answer: 42 });
}
6 changes: 6 additions & 0 deletions packages/kit/test/apps/basics/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,12 @@ test.describe('Load', () => {
expect(await page.textContent('h2')).toBe('the question was ?');
});

test('fetch resolves relative to layout', async ({ page, clicknav }) => {
await page.goto('/load');
await clicknav('[href="/load/fetch-layout-relative/a/b/c"]');
expect(await page.textContent('h1')).toBe('the answer is 42');
});

test('handles large responses', async ({ page }) => {
await page.goto('/load');

Expand Down

0 comments on commit 1d4e69a

Please sign in to comment.