Skip to content

Commit

Permalink
test: add test for refreshUnavailableParticipants
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisamir98 committed May 11, 2023
1 parent 5d0f7ef commit 74b7f82
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/script/conversation/ConversationRepository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*
*/

import {faker} from '@faker-js/faker';
import {ClientClassification} from '@wireapp/api-client/lib/client/';
import {ConnectionStatus} from '@wireapp/api-client/lib/connection/';
import {
Expand Down Expand Up @@ -1410,6 +1411,36 @@ describe('ConversationRepository', () => {
});
});

describe('refreshUnavailableParticipants', () => {
it('should refresh unavailable users', async () => {
const conversation = _generateConversation();
const unavailableUsers = [generateUser(), generateUser(), generateUser()].map(user => {
user.id = '';
user.name('');
return user;
});

conversation.participating_user_ets.push(unavailableUsers[0]);
conversation.participating_user_ets.push(unavailableUsers[1]);
conversation.participating_user_ets.push(unavailableUsers[2]);

const conversationRepo = await testFactory.exposeConversationActors();
spyOn(testFactory.user_repository!, 'refreshUsers').and.callFake(() => {
unavailableUsers.map(user => {
user.id = createUuid();
user.name(faker.name.fullName());
});
});

await conversationRepo.refreshUnavailableParticipants(conversation);

expect(testFactory.user_repository!.refreshUsers).toHaveBeenCalled();
expect(unavailableUsers[0].name).toBeTruthy();
expect(unavailableUsers[1].name).toBeTruthy();
expect(unavailableUsers[2].name).toBeTruthy();
});
});

describe('scheduleMissingUsersAndConversationsMetadataRefresh', () => {
beforeAll(() => {
jest.useFakeTimers();
Expand Down

0 comments on commit 74b7f82

Please sign in to comment.