Fix unit tests

pull/1238/head
Maxim Shishmarev 5 years ago
parent d747249d4f
commit 3faa4f71f3

@ -7,6 +7,8 @@ import { Stubs, TestUtils } from '../../test-utils';
import { UserUtil } from '../../../util'; import { UserUtil } from '../../../util';
import { SignalService } from '../../../protobuf'; import { SignalService } from '../../../protobuf';
import * as Ratchet from '../../../session/medium_group/ratchet';
// tslint:disable-next-line: max-func-body-length // tslint:disable-next-line: max-func-body-length
describe('MessageEncrypter', () => { describe('MessageEncrypter', () => {
const sandbox = sinon.createSandbox(); const sandbox = sinon.createSandbox();
@ -33,6 +35,7 @@ describe('MessageEncrypter', () => {
TestUtils.stubWindow('libloki', { TestUtils.stubWindow('libloki', {
crypto: { crypto: {
FallBackSessionCipher: Stubs.FallBackSessionCipherStub, FallBackSessionCipher: Stubs.FallBackSessionCipherStub,
encryptForPubkey: sinon.fake.returns(''),
} as any, } as any,
}); });
@ -46,15 +49,22 @@ describe('MessageEncrypter', () => {
describe('EncryptionType', () => { describe('EncryptionType', () => {
describe('MediumGroup', () => { describe('MediumGroup', () => {
it('should throw an error', async () => { it('should return a MEDIUM_GROUP_CIPHERTEXT envelope type', async () => {
const data = crypto.randomBytes(10); const data = crypto.randomBytes(10);
const promise = MessageEncrypter.encrypt(
sandbox.replace(
Ratchet,
'encryptWithSenderKey',
sinon.fake.returns({ ciphertext: '' })
);
const result = await MessageEncrypter.encrypt(
TestUtils.generateFakePubKey(), TestUtils.generateFakePubKey(),
data, data,
EncryptionType.MediumGroup EncryptionType.MediumGroup
); );
await expect(promise).to.be.rejectedWith( expect(result.envelopeType).to.deep.equal(
'Encryption is not yet supported' SignalService.Envelope.Type.MEDIUM_GROUP_CIPHERTEXT
); );
}); });
}); });

Loading…
Cancel
Save