36 lines
1018 B
JavaScript
36 lines
1018 B
JavaScript
|
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);
|
||
|
})
|
||
|
});
|
||
|
|
||
|
});
|