chore: refactor client sdk tests
This commit is contained in:
36
misc/client-sdk-testsuite/src/public/test/file-module.js
Normal file
36
misc/client-sdk-testsuite/src/public/test/file-module.js
Normal file
@ -0,0 +1,36 @@
|
||||
describe('File Module', function () {
|
||||
|
||||
before(() => {
|
||||
return Edge.connect();
|
||||
});
|
||||
|
||||
after(() => {
|
||||
Edge.disconnect();
|
||||
});
|
||||
|
||||
it('should upload then download a blob', function () {
|
||||
const content = JSON.stringify({ "date": new Date() });
|
||||
const blob = new Blob([content], { type: "application/json" });
|
||||
|
||||
return Edge.upload(blob)
|
||||
.then(upload => upload.result())
|
||||
.then(result => {
|
||||
|
||||
chai.assert.isNotEmpty(result.blobId);
|
||||
chai.assert.isNotEmpty(result.bucket);
|
||||
|
||||
const blobUrl = Edge.blobUrl(result.bucket, result.blobId);
|
||||
chai.assert.isNotEmpty(blobUrl);
|
||||
|
||||
return fetch(blobUrl)
|
||||
.then(res => res.text())
|
||||
.then(blobContent => {
|
||||
chai.assert.equal(content, blobContent);
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
chai.assert.fail(err);
|
||||
})
|
||||
});
|
||||
|
||||
});
|
Reference in New Issue
Block a user