add streaming
This commit is contained in:
parent
34cb970f11
commit
1bd7e4d486
16 changed files with 438 additions and 187 deletions
|
@ -3,21 +3,29 @@ import * as api from '../../../app/api';
|
|||
import Keychain from '../../../app/keychain';
|
||||
|
||||
const encoder = new TextEncoder();
|
||||
const plaintext = encoder.encode('hello world!');
|
||||
const plaintext = new Blob([encoder.encode('hello world!')]);
|
||||
const metadata = {
|
||||
name: 'test.txt',
|
||||
type: 'text/plain'
|
||||
};
|
||||
|
||||
describe('API', function() {
|
||||
describe('uploadFile', function() {
|
||||
describe('websocket upload', function() {
|
||||
it('returns file info on success', async function() {
|
||||
const keychain = new Keychain();
|
||||
const encrypted = await keychain.encryptFile(plaintext);
|
||||
const enc = await keychain.encryptStream(plaintext);
|
||||
const meta = await keychain.encryptMetadata(metadata);
|
||||
const verifierB64 = await keychain.authKeyB64();
|
||||
const p = function() {};
|
||||
const up = api.uploadFile(encrypted, meta, verifierB64, keychain, p);
|
||||
const up = await api.uploadWs(
|
||||
enc.stream,
|
||||
enc.streamInfo,
|
||||
meta,
|
||||
verifierB64,
|
||||
keychain,
|
||||
p
|
||||
);
|
||||
|
||||
const result = await up.result;
|
||||
assert.ok(result.url);
|
||||
assert.ok(result.id);
|
||||
|
@ -26,11 +34,18 @@ describe('API', function() {
|
|||
|
||||
it('can be cancelled', async function() {
|
||||
const keychain = new Keychain();
|
||||
const encrypted = await keychain.encryptFile(plaintext);
|
||||
const enc = await keychain.encryptStream(plaintext);
|
||||
const meta = await keychain.encryptMetadata(metadata);
|
||||
const verifierB64 = await keychain.authKeyB64();
|
||||
const p = function() {};
|
||||
const up = api.uploadFile(encrypted, meta, verifierB64, keychain, p);
|
||||
const up = await api.uploadWs(
|
||||
enc.stream,
|
||||
enc.streamInfo,
|
||||
meta,
|
||||
verifierB64,
|
||||
keychain,
|
||||
p
|
||||
);
|
||||
up.cancel();
|
||||
try {
|
||||
await up.result;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue