test: fix groups wrapper values test

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

@ -70,11 +70,11 @@ async function insertGroupsFromDBIntoWrapperAndRefresh(
return null; return null;
} }
if (!isUserGroupToStoreInWrapper(foundConvo)) { if (!SessionUtilUserGroups.isUserGroupToStoreInWrapper(foundConvo)) {
return null; return null;
} }
const convoType: UserGroupsType = isCommunityToStoreInWrapper(foundConvo) const convoType: UserGroupsType = SessionUtilUserGroups.isCommunityToStoreInWrapper(foundConvo)
? 'Community' ? 'Community'
: 'LegacyGroup'; : 'LegacyGroup';

@ -3,7 +3,6 @@ import { expect } from 'chai';
import { LegacyGroupInfo } from 'libsession_util_nodejs'; import { LegacyGroupInfo } from 'libsession_util_nodejs';
import { describe } from 'mocha'; import { describe } from 'mocha';
import Sinon from 'sinon'; import Sinon from 'sinon';
import { Data } from '../../../../data/data';
import { ConversationModel } from '../../../../models/conversation'; import { ConversationModel } from '../../../../models/conversation';
import { import {
CONVERSATION_PRIORITIES, CONVERSATION_PRIORITIES,
@ -173,19 +172,19 @@ describe('libsession_user_groups', () => {
displayNameInProfile: 'Test Group', displayNameInProfile: 'Test Group',
expirationMode: 'off', expirationMode: 'off',
expireTimer: 0, expireTimer: 0,
members: [groupECKeyPair.publicKeyData.toString()],
}; };
Sinon.stub(Data, 'getLatestClosedGroupEncryptionKeyPair').resolves(
groupECKeyPair.toHexKeyPair()
);
it('returns wrapper values that match with the inputted group', async () => { it('returns wrapper values that match with the inputted group', async () => {
const group = new ConversationModel({ const group = new ConversationModel({
...validArgs, ...validArgs,
...groupArgs, ...groupArgs,
} as any); } as any);
Sinon.stub(getConversationController(), 'get').returns(group); Sinon.stub(getConversationController(), 'get').returns(group);
// Sinon.stub(SessionUtilUserGroups, 'isLegacyGroupToStoreInWrapper').returns(true); Sinon.stub(SessionUtilUserGroups, 'isUserGroupToStoreInWrapper').returns(true);
TestUtils.stubData('getLatestClosedGroupEncryptionKeyPair').resolves(
groupECKeyPair.toHexKeyPair()
);
const wrapperGroup = await SessionUtilUserGroups.insertGroupsFromDBIntoWrapperAndRefresh( const wrapperGroup = await SessionUtilUserGroups.insertGroupsFromDBIntoWrapperAndRefresh(
group.get('id') group.get('id')
@ -208,22 +207,24 @@ describe('libsession_user_groups', () => {
(wrapperGroup as LegacyGroupInfo).priority, (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
.empty;
expect( expect(
(wrapperGroup as LegacyGroupInfo).members, (wrapperGroup as LegacyGroupInfo).members[0].pubkeyHex,
'members in the wrapper should match the inputted group' 'the member pubkey in the wrapper should match the inputted group member'
).to.equal(group.get('members')); ).to.equal(group.get('members')[0]);
expect( expect(
(wrapperGroup as LegacyGroupInfo).disappearingTimerSeconds, (wrapperGroup as LegacyGroupInfo).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, (wrapperGroup as LegacyGroupInfo).encPubkey.toString(),
'encPubkey in the wrapper should match the inputted group' 'encPubkey in the wrapper should match the inputted group'
).to.equal(groupECKeyPair.toHexKeyPair().publicHex); ).to.equal(groupECKeyPair.publicKeyData.toString());
expect( expect(
(wrapperGroup as LegacyGroupInfo).encSeckey, (wrapperGroup as LegacyGroupInfo).encSeckey.toString(),
'encSeckey in the wrapper should match the inputted group' 'encSeckey in the wrapper should match the inputted group'
).to.equal(groupECKeyPair.toHexKeyPair().privateHex); ).to.equal(groupECKeyPair.privateKeyData.toString());
expect( expect(
(wrapperGroup as LegacyGroupInfo).joinedAtSeconds, (wrapperGroup as LegacyGroupInfo).joinedAtSeconds,
'joinedAtSeconds in the wrapper should match the inputted group' 'joinedAtSeconds in the wrapper should match the inputted group'

Loading…
Cancel
Save