test: finished insertGroupsFromDBIntoWrapperAndRefresh

pull/2971/head
William Grant 2 years ago
parent a2890925a5
commit d89741cb29

@ -302,7 +302,7 @@ describe('libsession_contacts', () => {
).to.equal(contact.get('expirationMode')); ).to.equal(contact.get('expirationMode'));
expect( expect(
wrapperContact.expirationTimerSeconds, wrapperContact.expirationTimerSeconds,
'expirationTimerSeconds in the wrapper should match the inputted contact' 'expirationTimerSeconds in the wrapper should match the inputted contact expireTimer'
).to.equal(contact.get('expireTimer')); ).to.equal(contact.get('expireTimer'));
}); });
}); });

@ -186,7 +186,7 @@ describe('libsession_user_groups', () => {
groupECKeyPair.toHexKeyPair() groupECKeyPair.toHexKeyPair()
); );
const wrapperGroup = await SessionUtilUserGroups.insertGroupsFromDBIntoWrapperAndRefresh( let wrapperGroup = await SessionUtilUserGroups.insertGroupsFromDBIntoWrapperAndRefresh(
group.get('id') group.get('id')
); );
@ -195,69 +195,70 @@ describe('libsession_user_groups', () => {
throw Error('something should be returned from the wrapper'); throw Error('something should be returned from the wrapper');
} }
wrapperGroup = wrapperGroup as LegacyGroupInfo;
expect( expect(
(wrapperGroup as LegacyGroupInfo).pubkeyHex, wrapperGroup.pubkeyHex,
'pubkeyHex in the wrapper should match the inputted group' 'pubkeyHex in the wrapper should match the inputted group'
).to.equal(group.id); ).to.equal(group.id);
expect(wrapperGroup.name, 'name in the wrapper should match the inputted group').to.equal(
group.get('displayNameInProfile')
);
expect( expect(
(wrapperGroup as LegacyGroupInfo).name, wrapperGroup.priority,
'name in the wrapper should match the inputted group'
).to.equal(group.get('displayNameInProfile'));
expect(
(wrapperGroup as LegacyGroupInfo).priority,
'priority in the wrapper should match the inputted group' 'priority in the wrapper should match the inputted group'
).to.equal(group.get('priority')); ).to.equal(group.get('priority'));
expect((wrapperGroup as LegacyGroupInfo).members, 'members should not be empty').to.not.be expect(wrapperGroup.members, 'members should not be empty').to.not.be.empty;
.empty;
expect( expect(
(wrapperGroup as LegacyGroupInfo).members[0].pubkeyHex, wrapperGroup.members[0].pubkeyHex,
'the member pubkey in the wrapper should match the inputted group member' 'the member pubkey in the wrapper should match the inputted group member'
).to.equal(group.get('members')[0]); ).to.equal(group.get('members')[0]);
expect( expect(
(wrapperGroup as LegacyGroupInfo).disappearingTimerSeconds, wrapperGroup.disappearingTimerSeconds,
'disappearingTimerSeconds in the wrapper should match the inputted group' 'disappearingTimerSeconds in the wrapper should match the inputted group'
).to.equal(group.get('expireTimer')); ).to.equal(group.get('expireTimer'));
expect( expect(
(wrapperGroup as LegacyGroupInfo).encPubkey.toString(), wrapperGroup.encPubkey.toString(),
'encPubkey in the wrapper should match the inputted group' 'encPubkey in the wrapper should match the inputted group'
).to.equal(groupECKeyPair.publicKeyData.toString()); ).to.equal(groupECKeyPair.publicKeyData.toString());
expect( expect(
(wrapperGroup as LegacyGroupInfo).encSeckey.toString(), wrapperGroup.encSeckey.toString(),
'encSeckey in the wrapper should match the inputted group' 'encSeckey in the wrapper should match the inputted group'
).to.equal(groupECKeyPair.privateKeyData.toString()); ).to.equal(groupECKeyPair.privateKeyData.toString());
expect( expect(
(wrapperGroup as LegacyGroupInfo).joinedAtSeconds, wrapperGroup.joinedAtSeconds,
'joinedAtSeconds in the wrapper should match the inputted group' 'joinedAtSeconds in the wrapper should match the inputted group'
).to.equal(group.get('lastJoinedTimestamp')); ).to.equal(group.get('lastJoinedTimestamp'));
}); });
// it('if disappearing messages is on then the wrapper returned values should match the inputted group', async () => { it('if disappearing messages is on then the wrapper returned values should match the inputted group', async () => {
// const contact = new ConversationModel({ const group = new ConversationModel({
// ...validArgs, ...validArgs,
// ...groupArgs, ...groupArgs,
// expirationMode: 'deleteAfterSend', expirationMode: 'deleteAfterSend',
// expireTimer: 300, expireTimer: 300,
// } as any); } as any);
// Sinon.stub(getConversationController(), 'get').returns(contact); Sinon.stub(getConversationController(), 'get').returns(group);
// Sinon.stub(SessionUtilContact, 'isContactToStoreInWrapper').returns(true); Sinon.stub(SessionUtilUserGroups, 'isUserGroupToStoreInWrapper').returns(true);
TestUtils.stubData('getLatestClosedGroupEncryptionKeyPair').resolves(
groupECKeyPair.toHexKeyPair()
);
// const wrapperContact = await SessionUtilContact.insertContactFromDBIntoWrapperAndRefresh( let wrapperGroup = await SessionUtilUserGroups.insertGroupsFromDBIntoWrapperAndRefresh(
// contact.get('id') group.get('id')
// ); );
// expect(wrapperContact, 'something should be returned from the wrapper').to.not.be.null; expect(wrapperGroup, 'something should be returned from the wrapper').to.not.be.null;
// if (!wrapperContact) { if (!wrapperGroup) {
// throw Error('something should be returned from the wrapper'); throw Error('something should be returned from the wrapper');
// } }
wrapperGroup = wrapperGroup as LegacyGroupInfo;
// expect( expect(
// wrapperContact.expirationMode, wrapperGroup.disappearingTimerSeconds,
// 'expirationMode in the wrapper should match the inputted group' 'disappearingTimerSeconds in the wrapper should match the inputted group expireTimer'
// ).to.equal(contact.get('expirationMode')); ).to.equal(group.get('expireTimer'));
// expect( });
// wrapperContact.expirationTimerSeconds,
// 'expirationTimerSeconds in the wrapper should match the inputted group'
// ).to.equal(contact.get('expireTimer'));
// });
}); });
}); });
}); });

@ -131,7 +131,7 @@ describe('libsession_user_profile', () => {
expect( expect(
wrapperUserProfile.expirySeconds, wrapperUserProfile.expirySeconds,
'expirySeconds in the wrapper should match the inputted user profile' 'expirySeconds in the wrapper should match the inputted user profile expireTimer'
).to.equal(contact.get('expireTimer')); ).to.equal(contact.get('expireTimer'));
}); });
}); });

Loading…
Cancel
Save