Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robintown committed Jan 15, 2025
1 parent de3d553 commit eab2b9b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions test/unit-tests/stores/widgets/StopGapWidget-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,24 +118,24 @@ describe("StopGapWidget", () => {

it("feeds incoming event to the widget", async () => {
client.emit(ClientEvent.Event, event1);
expect(messaging.feedEvent).toHaveBeenCalledWith(event1.getEffectiveEvent(), "!1:example.org");
expect(messaging.feedEvent).toHaveBeenCalledWith(event1.getEffectiveEvent());

client.emit(ClientEvent.Event, event2);
expect(messaging.feedEvent).toHaveBeenCalledTimes(2);
expect(messaging.feedEvent).toHaveBeenLastCalledWith(event2.getEffectiveEvent(), "!1:example.org");
expect(messaging.feedEvent).toHaveBeenLastCalledWith(event2.getEffectiveEvent());
});

it("should not feed incoming event to the widget if seen already", async () => {
client.emit(ClientEvent.Event, event1);
expect(messaging.feedEvent).toHaveBeenCalledWith(event1.getEffectiveEvent(), "!1:example.org");
expect(messaging.feedEvent).toHaveBeenCalledWith(event1.getEffectiveEvent());

client.emit(ClientEvent.Event, event2);
expect(messaging.feedEvent).toHaveBeenCalledTimes(2);
expect(messaging.feedEvent).toHaveBeenLastCalledWith(event2.getEffectiveEvent(), "!1:example.org");
expect(messaging.feedEvent).toHaveBeenLastCalledWith(event2.getEffectiveEvent());

client.emit(ClientEvent.Event, event1);
expect(messaging.feedEvent).toHaveBeenCalledTimes(2);
expect(messaging.feedEvent).toHaveBeenLastCalledWith(event2.getEffectiveEvent(), "!1:example.org");
expect(messaging.feedEvent).toHaveBeenLastCalledWith(event2.getEffectiveEvent());
});

it("feeds decrypted events asynchronously", async () => {
Expand Down Expand Up @@ -165,7 +165,7 @@ describe("StopGapWidget", () => {
decryptingSpy2.mockReturnValue(false);
client.emit(MatrixEventEvent.Decrypted, event2Encrypted);
expect(messaging.feedEvent).toHaveBeenCalledTimes(1);
expect(messaging.feedEvent).toHaveBeenLastCalledWith(event2Encrypted.getEffectiveEvent(), "!1:example.org");
expect(messaging.feedEvent).toHaveBeenLastCalledWith(event2Encrypted.getEffectiveEvent());
// …then event 1
event1Encrypted.event.type = event1.getType();
event1Encrypted.event.content = event1.getContent();
Expand All @@ -175,7 +175,7 @@ describe("StopGapWidget", () => {
// doesn't have to be blocked on the decryption of event 1 (or
// worse, dropped)
expect(messaging.feedEvent).toHaveBeenCalledTimes(2);
expect(messaging.feedEvent).toHaveBeenLastCalledWith(event1Encrypted.getEffectiveEvent(), "!1:example.org");
expect(messaging.feedEvent).toHaveBeenLastCalledWith(event1Encrypted.getEffectiveEvent());
});

it("should not feed incoming event if not in timeline", () => {
Expand All @@ -191,7 +191,7 @@ describe("StopGapWidget", () => {
});

client.emit(ClientEvent.Event, event);
expect(messaging.feedEvent).toHaveBeenCalledWith(event.getEffectiveEvent(), "!1:example.org");
expect(messaging.feedEvent).toHaveBeenCalledWith(event.getEffectiveEvent());
});

it("feeds incoming event that is not in timeline but relates to unknown parent to the widget", async () => {
Expand All @@ -211,15 +211,15 @@ describe("StopGapWidget", () => {
});

client.emit(ClientEvent.Event, event1);
expect(messaging.feedEvent).toHaveBeenCalledWith(event1.getEffectiveEvent(), "!1:example.org");
expect(messaging.feedEvent).toHaveBeenCalledWith(event1.getEffectiveEvent());

client.emit(ClientEvent.Event, event);
expect(messaging.feedEvent).toHaveBeenCalledTimes(2);
expect(messaging.feedEvent).toHaveBeenLastCalledWith(event.getEffectiveEvent(), "!1:example.org");
expect(messaging.feedEvent).toHaveBeenLastCalledWith(event.getEffectiveEvent());

client.emit(ClientEvent.Event, event1);
expect(messaging.feedEvent).toHaveBeenCalledTimes(2);
expect(messaging.feedEvent).toHaveBeenLastCalledWith(event.getEffectiveEvent(), "!1:example.org");
expect(messaging.feedEvent).toHaveBeenLastCalledWith(event.getEffectiveEvent());
});
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/unit-tests/stores/widgets/StopGapWidgetDriver-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ describe("StopGapWidgetDriver", () => {

it("passes the flag through to getVisibleRooms", () => {
const driver = mkDefaultDriver();
driver.readRoomEvents(EventType.CallAnswer, "", 0, ["*"]);
driver.getKnownRooms();
expect(client.getVisibleRooms).toHaveBeenCalledWith(false);
});
});
Expand All @@ -584,7 +584,7 @@ describe("StopGapWidgetDriver", () => {

it("passes the flag through to getVisibleRooms", () => {
const driver = mkDefaultDriver();
driver.readRoomEvents(EventType.CallAnswer, "", 0, ["*"]);
driver.getKnownRooms();
expect(client.getVisibleRooms).toHaveBeenCalledWith(true);
});
});
Expand Down

0 comments on commit eab2b9b

Please sign in to comment.