Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy committed Jul 28, 2023
1 parent 5d93151 commit 4b01cde
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
18 changes: 14 additions & 4 deletions spec/unit/event-timeline-set.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,13 @@ describe("EventTimelineSet", () => {
messageEventIsDecryptionFailureSpy.mockReturnValue(true);
replyEventIsDecryptionFailureSpy.mockReturnValue(true);

messageEvent.emit(MatrixEventEvent.Decrypted, messageEvent);
replyEvent.emit(MatrixEventEvent.Decrypted, replyEvent);
messageEvent.emit(
MatrixEventEvent.Decrypted,
messageEvent,
undefined,
messageEvent.getPushDetails(),
);
replyEvent.emit(MatrixEventEvent.Decrypted, replyEvent, undefined, replyEvent.getPushDetails());

// simulate decryption
messageEventIsDecryptionFailureSpy.mockReturnValue(false);
Expand All @@ -313,8 +318,13 @@ describe("EventTimelineSet", () => {
messageEventShouldAttemptDecryptionSpy.mockReturnValue(false);
replyEventShouldAttemptDecryptionSpy.mockReturnValue(false);

messageEvent.emit(MatrixEventEvent.Decrypted, messageEvent);
replyEvent.emit(MatrixEventEvent.Decrypted, replyEvent);
messageEvent.emit(
MatrixEventEvent.Decrypted,
messageEvent,
undefined,
messageEvent.getPushDetails(),
);
replyEvent.emit(MatrixEventEvent.Decrypted, replyEvent, undefined, replyEvent.getPushDetails());
});

itShouldReturnTheRelatedEvents();
Expand Down
7 changes: 6 additions & 1 deletion spec/unit/room-state.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,12 @@ describe("RoomState", function () {

// this event is a message after decryption
decryptingRelatedEvent.event.type = EventType.RoomMessage;
decryptingRelatedEvent.emit(MatrixEventEvent.Decrypted, decryptingRelatedEvent);
decryptingRelatedEvent.emit(
MatrixEventEvent.Decrypted,
decryptingRelatedEvent,
undefined,
decryptingRelatedEvent.getPushDetails(),
);

expect(addLocationsSpy).not.toHaveBeenCalled();
});
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/room.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3428,13 +3428,13 @@ describe("Room", function () {
expect(room.polls.get(pollStartEventId)).toBeUndefined();

// now emit a Decrypted event but keep the decryption failure
pollStartEvent.emit(MatrixEventEvent.Decrypted, pollStartEvent);
pollStartEvent.emit(MatrixEventEvent.Decrypted, pollStartEvent, undefined, pollStartEvent.getPushDetails());
// still do not expect a poll to show up for the room
expect(room.polls.get(pollStartEventId)).toBeUndefined();

// clear decryption failure and emit a Decrypted event again
isDecryptionFailureSpy.mockRestore();
pollStartEvent.emit(MatrixEventEvent.Decrypted, pollStartEvent);
pollStartEvent.emit(MatrixEventEvent.Decrypted, pollStartEvent, undefined, pollStartEvent.getPushDetails());

// the poll should now show up in the room's polls
const poll = room.polls.get(pollStartEventId);
Expand Down

0 comments on commit 4b01cde

Please sign in to comment.