Skip to content

Commit

Permalink
Add some more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Sep 28, 2023
1 parent d2dc951 commit 98d76e6
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/fetch.ts
Expand Up @@ -45,3 +45,22 @@ test('fetch option takes a custom fetch function', async t => {
);
t.is(await ky('unicorn', {fetch: customFetch, prefixUrl: `${fixture}/api/`}).text(), `${fixture}/api/unicorn`);
});

test('options are correctly passed to Fetch #1', async t => {
t.plan(1);

const cache = 'no-store';

const customFetch: typeof fetch = async request => {
t.is(request.cache, cache);
return new Response(request.url);
};

await ky(fixture, {cache, fetch: customFetch}).text();
});

test('options are correctly passed to Fetch #2', async t => {
const fixture = {x: true};
const json = await ky.post('https://httpbin.org/anything', {json: fixture}).json();
t.deepEqual(json.json, fixture);
});

0 comments on commit 98d76e6

Please sign in to comment.