Fix getRelationsForEvent
under TypeScript strict
mode (#9558)
* Fix getRelationsForEvent tsc strictness * Use shared type for GetRelationsForEvent * Fix lint * Add alternative type * getRelationsForEvent is not required * Relations are optional * Reactions are optional * We expect relations in these tests * Add more protection if the eventID is not defined * Allow null too * Better test typing * User ID is not necessary unless something is selected * It's okay to [].includes(null) * Null is as good as undefined here * Null or undefined is good here * We have some expectations for the tests * The room and user can be undefined too * Protec * Reactions are optional * Try match signatures * Null or undefined * More null or undefined * Protec * Fix typo (wrong variable) * Remove optional params See https://github.com/matrix-org/matrix-react-sdk/pull/9558#discussion_r1017515913 * Fix up last maaaaybe relevant lint Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
2cd1fad10b
commit
2393510a7f
15 changed files with 181 additions and 126 deletions
|
@ -321,12 +321,13 @@ describe("MPollBody", () => {
|
|||
const votes = [responseEvent("@me:example.com", "pizza", 100)];
|
||||
const body = newMPollBody(votes);
|
||||
const props: IBodyProps = body.instance().props as IBodyProps;
|
||||
const voteRelations: Relations = props.getRelationsForEvent(
|
||||
const voteRelations = props!.getRelationsForEvent!(
|
||||
"$mypoll", "m.reference", M_POLL_RESPONSE.name);
|
||||
expect(voteRelations).toBeDefined();
|
||||
clickRadio(body, "pizza");
|
||||
|
||||
// When a new vote from me comes in
|
||||
voteRelations.addEvent(responseEvent("@me:example.com", "wings", 101));
|
||||
voteRelations!.addEvent(responseEvent("@me:example.com", "wings", 101));
|
||||
|
||||
// Then the new vote is counted, not the old one
|
||||
expect(votesCount(body, "pizza")).toBe("0 votes");
|
||||
|
@ -342,12 +343,13 @@ describe("MPollBody", () => {
|
|||
const votes = [responseEvent("@me:example.com", "pizza")];
|
||||
const body = newMPollBody(votes);
|
||||
const props: IBodyProps = body.instance().props as IBodyProps;
|
||||
const voteRelations: Relations = props.getRelationsForEvent(
|
||||
const voteRelations = props!.getRelationsForEvent!(
|
||||
"$mypoll", "m.reference", M_POLL_RESPONSE.name);
|
||||
expect(voteRelations).toBeDefined();
|
||||
clickRadio(body, "pizza");
|
||||
|
||||
// When a new vote from someone else comes in
|
||||
voteRelations.addEvent(responseEvent("@xx:example.com", "wings", 101));
|
||||
voteRelations!.addEvent(responseEvent("@xx:example.com", "wings", 101));
|
||||
|
||||
// Then my vote is still for pizza
|
||||
// NOTE: the new event does not affect the counts for other people -
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue