Skip to content
Myr

Fix empty `context` object being added to merged `json` body

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fixes #820

authored by Sindre Sorhus · committed by Sindre Sorhus · parent 51b0129 · Browse files · 2 files+25 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+25 added−4 removed

  • tests:+25 added−0 removed
  • other:+0 added−4 removed

2 files+25 added−4 removed

modified:source/utils/merge.ts-4 removed
modified:test/main.ts+25 added
729 unmodified lines
730731 await server.close();732});733734test('ky.create() with default json does not add context to merged json body', async t => {735 const server = await createHttpTestServer();736 server.post('/', async (request, response) => {737 response.json(request.body);738 });739740 const api = ky.create({741 prefixUrl: server.url,742 json: {743 foo: 'bar',744 },745 });746747 const result = await api.post('', {748 json: {749 baz: 'baz',750 },751 }).json<Record<string, unknown>>();752753 t.deepEqual(result, {foo: 'bar', baz: 'baz'});754 t.false('context' in result);755756 await server.close();757});758759const extendHooksMacro = test.macro<[{useFunction: boolean}]>(async (t, {useFunction}) => {760 const server = await createHttpTestServer();761 server.get('/', (_request, response) => {762 response.end();
379 unmodified lines