Skip to content

Commit

Permalink
Fix Storage Node tests (#8443)
Browse files Browse the repository at this point in the history
  • Loading branch information
dlarocque committed Aug 20, 2024
1 parent 1ff9661 commit 12ba46f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/storage/test/integration/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,5 @@ describe('FirebaseStorage Exp', () => {
await task;
const bytes = await getBytes(referenceA);
expect(bytes).to.deep.eq(bytesToUpload);
});
}).timeout(10_000);
});
24 changes: 8 additions & 16 deletions packages/storage/test/unit/requests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,6 @@ describe('Firebase Storage > Requests', () => {

const metadataContentType = 'application/json; charset=utf-8';

function readBlob(blob: Blob): Promise<string> {
const reader = new FileReader();
reader.readAsText(blob);
return new Promise((resolve, reject) => {
reader.onload = () => {
resolve(reader.result as string);
};
reader.onerror = () => {
reject(reader.error as Error);
};
});
}

async function assertBodyEquals(
body: Blob | string | Uint8Array | null,
expectedStr: string
Expand All @@ -167,9 +154,14 @@ describe('Firebase Storage > Requests', () => {
}

if (typeof Blob !== 'undefined' && body instanceof Blob) {
return readBlob(body).then(str => {
assert.equal(str, expectedStr);
});
return body
.text()
.then(str => {
assert.equal(str, expectedStr);
})
.catch(err => {
return Promise.reject(err);
});
} else if (body instanceof Uint8Array) {
const str = decodeUint8Array(body);
assert.equal(str, expectedStr);
Expand Down

0 comments on commit 12ba46f

Please sign in to comment.