From bf690868f18356161c3ed22070cb61e1eac4c9db Mon Sep 17 00:00:00 2001 From: William Grant Date: Wed, 11 Oct 2023 17:07:30 +1100 Subject: [PATCH] test: stub libsession workers in all places instead of stub the set function --- .../libsession_wrapper/libsession_wrapper_contacts_test.ts | 6 +++--- .../libsession_wrapper_user_profile_test.ts | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/ts/test/session/unit/libsession_wrapper/libsession_wrapper_contacts_test.ts b/ts/test/session/unit/libsession_wrapper/libsession_wrapper_contacts_test.ts index d81b5e607..4bcfb0683 100644 --- a/ts/test/session/unit/libsession_wrapper/libsession_wrapper_contacts_test.ts +++ b/ts/test/session/unit/libsession_wrapper/libsession_wrapper_contacts_test.ts @@ -10,7 +10,7 @@ import { GetNetworkTime } from '../../../../session/apis/snode_api/getNetworkTim import { getConversationController } from '../../../../session/conversations'; import { UserUtils } from '../../../../session/utils'; import { SessionUtilContact } from '../../../../session/utils/libsession/libsession_utils_contacts'; -import { ContactsWrapperActions } from '../../../../webworker/workers/browser/libsession_worker_interface'; +import { TestUtils } from '../../../test-utils'; import { stubWindowLog } from '../../../test-utils/utils/stubbing'; describe('libsession_contacts', () => { @@ -30,7 +30,9 @@ describe('libsession_contacts', () => { beforeEach(() => { Sinon.stub(GetNetworkTime, 'getLatestTimestampOffset').returns(getLatestTimestampOffset); Sinon.stub(UserUtils, 'getOurPubKeyStrFromCache').returns(ourNumber); + TestUtils.stubLibSessionWorker(undefined); }); + afterEach(() => { Sinon.restore(); }); @@ -230,7 +232,6 @@ describe('libsession_contacts', () => { } as any); Sinon.stub(getConversationController(), 'get').returns(contact); Sinon.stub(SessionUtilContact, 'isContactToStoreInWrapper').returns(true); - Sinon.stub(ContactsWrapperActions, 'set').resolves(); const wrapperContact = await SessionUtilContact.insertContactFromDBIntoWrapperAndRefresh( contact.get('id') @@ -285,7 +286,6 @@ describe('libsession_contacts', () => { } as any); Sinon.stub(getConversationController(), 'get').returns(contact); Sinon.stub(SessionUtilContact, 'isContactToStoreInWrapper').returns(true); - Sinon.stub(ContactsWrapperActions, 'set').resolves(); const wrapperContact = await SessionUtilContact.insertContactFromDBIntoWrapperAndRefresh( contact.get('id') diff --git a/ts/test/session/unit/libsession_wrapper/libsession_wrapper_user_profile_test.ts b/ts/test/session/unit/libsession_wrapper/libsession_wrapper_user_profile_test.ts index 040565e99..6bdc40cbf 100644 --- a/ts/test/session/unit/libsession_wrapper/libsession_wrapper_user_profile_test.ts +++ b/ts/test/session/unit/libsession_wrapper/libsession_wrapper_user_profile_test.ts @@ -63,7 +63,6 @@ describe('libsession_user_profile', () => { } as any); Sinon.stub(getConversationController(), 'get').returns(contact); Sinon.stub(SessionUtilUserProfile, 'isUserProfileToStoreInWrapper').returns(true); - // Sinon.stub(ContactsWrapperActions, 'set').resolves(); const wrapperUserProfile = await SessionUtilUserProfile.insertUserProfileIntoWrapper( ourNumber @@ -103,7 +102,6 @@ describe('libsession_user_profile', () => { } as any); Sinon.stub(getConversationController(), 'get').returns(contact); Sinon.stub(SessionUtilUserProfile, 'isUserProfileToStoreInWrapper').returns(true); - // Sinon.stub(ContactsWrapperActions, 'set').resolves(); try { await SessionUtilUserProfile.insertUserProfileIntoWrapper(ourNumber); @@ -121,7 +119,6 @@ describe('libsession_user_profile', () => { } as any); Sinon.stub(getConversationController(), 'get').returns(contact); Sinon.stub(SessionUtilUserProfile, 'isUserProfileToStoreInWrapper').returns(true); - // Sinon.stub(ContactsWrapperActions, 'set').resolves(); const wrapperUserProfile = await SessionUtilUserProfile.insertUserProfileIntoWrapper( ourNumber