extracted blobSlicer, fixed download cancel tests
This commit is contained in:
parent
5483dc2506
commit
5e9e63944b
6 changed files with 58 additions and 58 deletions
|
@ -3,6 +3,7 @@ require('buffer');
|
|||
|
||||
import assert from 'assert';
|
||||
import { b64ToArray } from '../../../app/utils';
|
||||
import BlobSlicer from '../../../app/blobSlicer';
|
||||
import ECE from '../../../app/ece.js';
|
||||
|
||||
const rs = 36;
|
||||
|
@ -47,8 +48,10 @@ describe('Streaming', function() {
|
|||
});
|
||||
|
||||
it('can decrypt', async function() {
|
||||
const encBlob = new Blob([encrypted]);
|
||||
const ece = new ECE(encBlob, key, 'decrypt', rs);
|
||||
const blobStream = new ReadableStream(
|
||||
new BlobSlicer(new Blob([encrypted]), rs)
|
||||
);
|
||||
const ece = new ECE(blobStream, key, 'decrypt', rs);
|
||||
const decStream = await ece.transform();
|
||||
|
||||
const reader = decStream.getReader();
|
||||
|
|
|
@ -153,26 +153,26 @@ describe('Upload / Download flow', function() {
|
|||
assert.equal(file.dtotal, 1);
|
||||
});
|
||||
|
||||
// it('does not increase download count when download cancelled', async function() {
|
||||
// const fs = new FileSender(blob);
|
||||
// const file = await fs.upload();
|
||||
// const fr = new FileReceiver({
|
||||
// secretKey: file.toJSON().secretKey,
|
||||
// id: file.id,
|
||||
// nonce: file.keychain.nonce,
|
||||
// requiresPassword: false
|
||||
// });
|
||||
// await fr.getMetadata();
|
||||
// fr.once('progress', () => fr.cancel());
|
||||
it('does not increase download count when download cancelled', async function() {
|
||||
const fs = new FileSender(blob);
|
||||
const file = await fs.upload();
|
||||
const fr = new FileReceiver({
|
||||
secretKey: file.toJSON().secretKey,
|
||||
id: file.id,
|
||||
nonce: file.keychain.nonce,
|
||||
requiresPassword: false
|
||||
});
|
||||
await fr.getMetadata();
|
||||
fr.once('progress', () => fr.cancel());
|
||||
|
||||
// try {
|
||||
// await fr.download(noSave);
|
||||
// assert.fail('not cancelled');
|
||||
// } catch (e) {
|
||||
// await file.updateDownloadCount();
|
||||
// assert.equal(file.dtotal, 0);
|
||||
// }
|
||||
// });
|
||||
try {
|
||||
await fr.download(noSave);
|
||||
assert.fail('not cancelled');
|
||||
} catch (e) {
|
||||
await file.updateDownloadCount();
|
||||
assert.equal(file.dtotal, 0);
|
||||
}
|
||||
});
|
||||
|
||||
it('can allow multiple downloads', async function() {
|
||||
const fs = new FileSender(blob);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue