fix(misskey-js): drive/file/createが動かない問題を修正
This commit is contained in:
parent
ed3a844f5d
commit
f6ec7795eb
|
@ -106,7 +106,7 @@ export class APIClient {
|
|||
this.fetch(`${this.origin}/api/${endpoint}`, {
|
||||
method: 'POST',
|
||||
body: payload,
|
||||
headers: {
|
||||
headers: mediaType === 'multipart/form-data' ? {} : {
|
||||
'Content-Type': mediaType,
|
||||
},
|
||||
credentials: 'omit',
|
||||
|
|
|
@ -94,11 +94,7 @@ describe('API', () => {
|
|||
fetchMock.resetMocks();
|
||||
fetchMock.mockResponse(async (req) => {
|
||||
if (req.method == 'POST' && req.url == 'https://misskey.test/api/drive/files/create') {
|
||||
if (req.headers.get('Content-Type')?.includes('multipart/form-data')) {
|
||||
return JSON.stringify({ id: 'foo' });
|
||||
} else {
|
||||
return { status: 400 };
|
||||
}
|
||||
return JSON.stringify({ id: 'foo' });
|
||||
} else {
|
||||
return { status: 404 };
|
||||
}
|
||||
|
@ -123,7 +119,7 @@ describe('API', () => {
|
|||
expect(getFetchCall(fetchMock.mock.calls[0])).toEqual({
|
||||
url: 'https://misskey.test/api/drive/files/create',
|
||||
method: 'POST',
|
||||
contentType: 'multipart/form-data',
|
||||
contentType: undefined,
|
||||
body: {
|
||||
i: 'TOKEN',
|
||||
file: testFile,
|
||||
|
|
Loading…
Reference in New Issue