diff --git a/spec/unit/models/poll.spec.ts b/spec/unit/models/poll.spec.ts index 245d5646501..d0261a3f342 100644 --- a/spec/unit/models/poll.spec.ts +++ b/spec/unit/models/poll.spec.ts @@ -76,6 +76,7 @@ describe("Poll", () => { expect(poll.pollId).toEqual(basePollStartEvent.getId()); expect(poll.pollEvent).toEqual(basePollStartEvent.unstableExtensibleEvent); expect(poll.isEnded).toBe(false); + expect(poll.endEventId).toBe(undefined); }); it("throws when poll start has no room id", () => { @@ -208,6 +209,7 @@ describe("Poll", () => { expect(maySendRedactionForEventSpy).toHaveBeenCalledWith(basePollStartEvent, "@bob@server.org"); expect(poll.isEnded).toBe(true); + expect(poll.endEventId).toBe(stablePollEndEvent.getId()!); expect(poll.emit).toHaveBeenCalledWith(PollEvent.End); }); diff --git a/src/models/poll.ts b/src/models/poll.ts index 8a080ef9015..89f18165377 100644 --- a/src/models/poll.ts +++ b/src/models/poll.ts @@ -80,6 +80,10 @@ export class Poll extends TypedEventEmitter, P return this.rootEvent.getId()!; } + public get endEventId(): string | undefined { + return this.endEvent?.getId(); + } + public get isEnded(): boolean { return !!this.endEvent; }