Skip to content

Commit fef12f3

Browse files
committed
test: テストコード修正
1 parent e28924f commit fef12f3

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/createClient.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ export const createClient = ({
298298
const requestInit: MakeRequest['requestInit'] = {
299299
...customRequestInit,
300300
method: 'DELETE',
301+
headers: {},
302+
body: undefined,
301303
};
302304

303305
await makeRequest({ endpoint, contentId, requestInit });

tests/requestInit.test.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ describe('requestInit', () => {
118118
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
119119
// @ts-expect-error
120120
expect(fetchMock.mock.calls[0][1]).toEqual({
121-
method: 'POST',
121+
method: 'PATCH',
122122
headers: new Headers({
123123
'Content-Type': 'application/json',
124124
'X-MICROCMS-API-KEY': 'apiKey',
@@ -130,26 +130,23 @@ describe('requestInit', () => {
130130
test('Custom request init added method, headers and body parameters is not overwrited for fetch in delete request.', async () => {
131131
await client.delete({
132132
endpoint: 'list-type',
133-
content: { title: 'title' },
133+
contentId: 'contentId',
134134
customRequestInit: {
135135
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
136136
// @ts-expect-error
137137
method: 'GET',
138138
headers: {
139139
'X-MICROCMS-API-KEY': 'OverwrittenApiKey',
140140
},
141-
body: { title: 'Overwritten Title' },
142141
},
143142
});
144143
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
145144
// @ts-expect-error
146145
expect(fetchMock.mock.calls[0][1]).toEqual({
147-
method: 'POST',
146+
method: 'DELETE',
148147
headers: new Headers({
149-
'Content-Type': 'application/json',
150148
'X-MICROCMS-API-KEY': 'apiKey',
151149
}),
152-
body: JSON.stringify({ title: 'title' }),
153150
});
154151
});
155152
});

0 commit comments

Comments
 (0)