More descriptive tests

// FREEBIE
pull/749/head
lilia 9 years ago
parent f173104c82
commit 348ee0b3e7

@ -20,17 +20,22 @@ describe("SignalProtocolStore", function() {
pubKey: textsecure.crypto.getRandomBytes(33),
privKey: textsecure.crypto.getRandomBytes(32),
};
describe('getLocalRegistrationId', function() {
it('retrieves my registration id', function(done) {
store.getLocalRegistrationId().then(function(reg) {
assert.strictEqual(reg, 1337);
}).then(done, done);
});
});
describe('getIdentityKeyPair', function() {
it('retrieves my identity key', function(done) {
store.getIdentityKeyPair().then(function(key) {
assertEqualArrayBuffers(key.pubKey, identityKey.pubKey);
assertEqualArrayBuffers(key.privKey, identityKey.privKey);
}).then(done,done);
});
});
describe('putIdentityKey', function() {
it('stores identity keys', function(done) {
store.putIdentityKey(identifier, testKey.pubKey).then(function() {
return store.loadIdentityKey(identifier).then(function(key) {
@ -49,6 +54,8 @@ describe("SignalProtocolStore", function() {
});
});
});
});
describe('isTrustedIdentity', function() {
it('returns true if a key is trusted', function(done) {
store.putIdentityKey(identifier, testKey.pubKey).then(function() {
store.isTrustedIdentity(identifier, testKey.pubKey).then(function(trusted) {
@ -72,6 +79,8 @@ describe("SignalProtocolStore", function() {
}).catch(done);
});
});
});
describe('storePreKey', function() {
it('stores prekeys', function(done) {
store.storePreKey(1, testKey).then(function() {
return store.loadPreKey(1).then(function(key) {
@ -80,6 +89,8 @@ describe("SignalProtocolStore", function() {
});
}).then(done,done);
});
});
describe('removePreKey', function() {
it('deletes prekeys', function(done) {
before(function(done) {
store.storePreKey(2, testKey).then(done);
@ -90,6 +101,8 @@ describe("SignalProtocolStore", function() {
});
}).then(done,done);
});
});
describe('storeSignedPreKey', function() {
it('stores signed prekeys', function(done) {
store.storeSignedPreKey(3, testKey).then(function() {
return store.loadSignedPreKey(3).then(function(key) {
@ -98,6 +111,8 @@ describe("SignalProtocolStore", function() {
});
}).then(done,done);
});
});
describe('removeSignedPreKey', function() {
it('deletes signed prekeys', function(done) {
before(function(done) {
store.storeSignedPreKey(4, testKey).then(done);
@ -108,6 +123,8 @@ describe("SignalProtocolStore", function() {
});
}).then(done,done);
});
});
describe('storeSession', function() {
it('stores sessions', function(done) {
var testRecord = "an opaque string";
store.storeSession(identifier + '.1', testRecord).then(function() {
@ -116,6 +133,8 @@ describe("SignalProtocolStore", function() {
});
}).then(done,done);
});
});
describe('removeAllSessions', function() {
it('removes all sessions for a number', function(done) {
var testRecord = "an opaque string";
var devices = [1, 2, 3].map(function(deviceId) {
@ -137,6 +156,8 @@ describe("SignalProtocolStore", function() {
});
}).then(done,done);
});
});
describe('clearSessionStore', function() {
it ('clears the session store', function(done) {
var testRecord = "an opaque string";
store.storeSession(identifier + '.1', testRecord).then(function() {
@ -148,6 +169,8 @@ describe("SignalProtocolStore", function() {
}).then(done,done);
});
});
describe('getDeviceIds', function() {
it('returns deviceIds for a number', function(done) {
var testRecord = "an opaque string";
var devices = [1, 2, 3].map(function(deviceId) {
@ -170,4 +193,5 @@ describe("SignalProtocolStore", function() {
assert.sameMembers(deviceIds,[]);
}).then(done,done);
});
});
});

Loading…
Cancel
Save