test: improve coverage on affine api (#1727)

This commit is contained in:
Himself65
2023-03-28 12:42:40 -05:00
committed by GitHub
parent 751ad9716f
commit dbbc05e5f0
7 changed files with 119 additions and 48 deletions

View File

@@ -295,22 +295,26 @@ export function createWorkspaceApis(prefixUrl = '/') {
throw new RequestError(MessageCode.acceptInvitingFailed, e);
});
},
uploadBlob: async (workspaceId: string, blob: Blob): Promise<string> => {
uploadBlob: async (
workspaceId: string,
arrayBuffer: ArrayBuffer,
type: string
): Promise<string> => {
const auth = getLoginStorage();
assertExists(auth);
return fetch(prefixUrl + 'api/blob', {
method: 'PUT',
body: blob,
body: arrayBuffer,
headers: {
'Content-Type': blob.type,
'Content-Type': type,
Authorization: auth.token,
},
}).then(r => r.text());
},
getBlob: async (params: { blobId: string }): Promise<ArrayBuffer> => {
getBlob: async (blobId: string): Promise<ArrayBuffer> => {
const auth = getLoginStorage();
assertExists(auth);
return fetch(prefixUrl + `api/blob/${params.blobId}`, {
return fetch(prefixUrl + `api/blob/${blobId}`, {
method: 'GET',
headers: {
Authorization: auth.token,