Skip to content
This repository was archived by the owner on Oct 22, 2024. It is now read-only.

Commit b2b818a

Browse files
committed
Step 8.6: Fix TS issues introduced by using imports
1 parent 9a75acb commit b2b818a

File tree

5 files changed

+71
-6
lines changed

5 files changed

+71
-6
lines changed

test/components/views/messages/DateSeparator-test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ describe("DateSeparator", () => {
3636
const defaultProps = {
3737
ts: nowMs,
3838
now,
39+
roomId: "!unused:example.org",
3940
};
4041
const RealDate = global.Date;
4142
class MockDate extends Date {

test/components/views/messages/MPollBody-test.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,14 @@ function newMPollBodyFromEvent(
10721072
}
10731073
}
10741074
}
1075+
1076+
// We don't use any of these props, but they're required.
1077+
highlightLink="unused"
1078+
highlights={[]}
1079+
mediaEventHelper={null}
1080+
onHeightChanged={() => {}}
1081+
onMessageAllowed={() => {}}
1082+
permalinkCreator={null}
10751083
/>, {
10761084
wrappingComponent: MatrixClientContext.Provider,
10771085
wrappingComponentProps: {

test/components/views/messages/__snapshots__/DateSeparator-test.tsx.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
exports[`DateSeparator renders the date separator correctly 1`] = `
44
<DateSeparator
55
now="2021-12-17T08:09:00.000Z"
6+
roomId="!unused:example.org"
67
ts={1639728540000}
78
>
89
<h2
@@ -29,6 +30,7 @@ exports[`DateSeparator renders the date separator correctly 1`] = `
2930
exports[`DateSeparator when feature_jump_to_date is enabled renders the date separator correctly 1`] = `
3031
<DateSeparator
3132
now="2021-12-17T08:09:00.000Z"
33+
roomId="!unused:example.org"
3234
ts={1639728540000}
3335
>
3436
<h2

test/components/views/messages/__snapshots__/MPollBody-test.tsx.snap

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
exports[`MPollBody renders a finished poll 1`] = `
44
<MPollBody
55
getRelationsForEvent={[Function]}
6+
highlightLink="unused"
7+
highlights={Array []}
8+
mediaEventHelper={null}
69
mxEvent={
710
Object {
811
"content": Object {
@@ -41,6 +44,9 @@ exports[`MPollBody renders a finished poll 1`] = `
4144
"type": "org.matrix.msc3381.poll.start",
4245
}
4346
}
47+
onHeightChanged={[Function]}
48+
onMessageAllowed={[Function]}
49+
permalinkCreator={null}
4450
>
4551
<div
4652
className="mx_MPollBody"
@@ -312,6 +318,9 @@ exports[`MPollBody renders a finished poll 1`] = `
312318
exports[`MPollBody renders a finished poll with multiple winners 1`] = `
313319
<MPollBody
314320
getRelationsForEvent={[Function]}
321+
highlightLink="unused"
322+
highlights={Array []}
323+
mediaEventHelper={null}
315324
mxEvent={
316325
Object {
317326
"content": Object {
@@ -350,6 +359,9 @@ exports[`MPollBody renders a finished poll with multiple winners 1`] = `
350359
"type": "org.matrix.msc3381.poll.start",
351360
}
352361
}
362+
onHeightChanged={[Function]}
363+
onMessageAllowed={[Function]}
364+
permalinkCreator={null}
353365
>
354366
<div
355367
className="mx_MPollBody"
@@ -621,6 +633,9 @@ exports[`MPollBody renders a finished poll with multiple winners 1`] = `
621633
exports[`MPollBody renders a finished poll with no votes 1`] = `
622634
<MPollBody
623635
getRelationsForEvent={[Function]}
636+
highlightLink="unused"
637+
highlights={Array []}
638+
mediaEventHelper={null}
624639
mxEvent={
625640
Object {
626641
"content": Object {
@@ -659,6 +674,9 @@ exports[`MPollBody renders a finished poll with no votes 1`] = `
659674
"type": "org.matrix.msc3381.poll.start",
660675
}
661676
}
677+
onHeightChanged={[Function]}
678+
onMessageAllowed={[Function]}
679+
permalinkCreator={null}
662680
>
663681
<div
664682
className="mx_MPollBody"
@@ -930,6 +948,9 @@ exports[`MPollBody renders a finished poll with no votes 1`] = `
930948
exports[`MPollBody renders a poll that I have not voted in 1`] = `
931949
<MPollBody
932950
getRelationsForEvent={[Function]}
951+
highlightLink="unused"
952+
highlights={Array []}
953+
mediaEventHelper={null}
933954
mxEvent={
934955
Object {
935956
"content": Object {
@@ -968,6 +989,9 @@ exports[`MPollBody renders a poll that I have not voted in 1`] = `
968989
"type": "org.matrix.msc3381.poll.start",
969990
}
970991
}
992+
onHeightChanged={[Function]}
993+
onMessageAllowed={[Function]}
994+
permalinkCreator={null}
971995
>
972996
<div
973997
className="mx_MPollBody"
@@ -1339,6 +1363,9 @@ exports[`MPollBody renders a poll that I have not voted in 1`] = `
13391363
exports[`MPollBody renders a poll with local, non-local and invalid votes 1`] = `
13401364
<MPollBody
13411365
getRelationsForEvent={[Function]}
1366+
highlightLink="unused"
1367+
highlights={Array []}
1368+
mediaEventHelper={null}
13421369
mxEvent={
13431370
Object {
13441371
"content": Object {
@@ -1377,6 +1404,9 @@ exports[`MPollBody renders a poll with local, non-local and invalid votes 1`] =
13771404
"type": "org.matrix.msc3381.poll.start",
13781405
}
13791406
}
1407+
onHeightChanged={[Function]}
1408+
onMessageAllowed={[Function]}
1409+
permalinkCreator={null}
13801410
>
13811411
<div
13821412
className="mx_MPollBody"
@@ -1756,6 +1786,9 @@ exports[`MPollBody renders a poll with local, non-local and invalid votes 1`] =
17561786
exports[`MPollBody renders a poll with no votes 1`] = `
17571787
<MPollBody
17581788
getRelationsForEvent={[Function]}
1789+
highlightLink="unused"
1790+
highlights={Array []}
1791+
mediaEventHelper={null}
17591792
mxEvent={
17601793
Object {
17611794
"content": Object {
@@ -1794,6 +1827,9 @@ exports[`MPollBody renders a poll with no votes 1`] = `
17941827
"type": "org.matrix.msc3381.poll.start",
17951828
}
17961829
}
1830+
onHeightChanged={[Function]}
1831+
onMessageAllowed={[Function]}
1832+
permalinkCreator={null}
17971833
>
17981834
<div
17991835
className="mx_MPollBody"
@@ -2165,6 +2201,9 @@ exports[`MPollBody renders a poll with no votes 1`] = `
21652201
exports[`MPollBody renders a poll with only non-local votes 1`] = `
21662202
<MPollBody
21672203
getRelationsForEvent={[Function]}
2204+
highlightLink="unused"
2205+
highlights={Array []}
2206+
mediaEventHelper={null}
21682207
mxEvent={
21692208
Object {
21702209
"content": Object {
@@ -2203,6 +2242,9 @@ exports[`MPollBody renders a poll with only non-local votes 1`] = `
22032242
"type": "org.matrix.msc3381.poll.start",
22042243
}
22052244
}
2245+
onHeightChanged={[Function]}
2246+
onMessageAllowed={[Function]}
2247+
permalinkCreator={null}
22062248
>
22072249
<div
22082250
className="mx_MPollBody"

test/components/views/rooms/MessageComposerButtons-test.tsx

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ import { IRoomState } from "../../../../src/components/structures/RoomView";
2727
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
2828
import MessageComposerButtons from "../../../../src/components/views/rooms/MessageComposerButtons";
2929

30+
// @ts-ignore - we're deliberately not implementing the whole interface here, but
31+
// can't use Partial<> for types because it'll annoy TS more than it helps.
32+
const mockProps: React.ComponentProps<typeof MessageComposerButtons> = {
33+
addEmoji: () => false,
34+
haveRecording: false,
35+
isStickerPickerOpen: false,
36+
menuPosition: null,
37+
onRecordStartEndClick: () => {},
38+
setStickerPickerOpen: () => {},
39+
toggleButtonMenu: () => {},
40+
};
41+
3042
describe("MessageComposerButtons", () => {
3143
it("Renders emoji and upload buttons in wide mode", () => {
3244
const buttons = wrapAndRender(
@@ -35,7 +47,7 @@ describe("MessageComposerButtons", () => {
3547
showLocationButton={true}
3648
showPollsButton={true}
3749
showStickersButton={true}
38-
toggleButtonMenu={() => {}}
50+
{...mockProps}
3951
/>,
4052
false,
4153
);
@@ -54,7 +66,7 @@ describe("MessageComposerButtons", () => {
5466
showLocationButton={true}
5567
showPollsButton={true}
5668
showStickersButton={true}
57-
toggleButtonMenu={() => {}}
69+
{...mockProps}
5870
/>,
5971
false,
6072
);
@@ -79,7 +91,7 @@ describe("MessageComposerButtons", () => {
7991
showLocationButton={true}
8092
showPollsButton={true}
8193
showStickersButton={true}
82-
toggleButtonMenu={() => {}}
94+
{...mockProps}
8395
/>,
8496
true,
8597
);
@@ -97,7 +109,7 @@ describe("MessageComposerButtons", () => {
97109
showLocationButton={true}
98110
showPollsButton={true}
99111
showStickersButton={true}
100-
toggleButtonMenu={() => {}}
112+
{...mockProps}
101113
/>,
102114
true,
103115
);
@@ -122,7 +134,7 @@ describe("MessageComposerButtons", () => {
122134
showLocationButton={true}
123135
showPollsButton={true}
124136
showStickersButton={true}
125-
toggleButtonMenu={() => {}}
137+
{...mockProps}
126138
/>,
127139
true,
128140
);
@@ -146,7 +158,7 @@ describe("MessageComposerButtons", () => {
146158
showLocationButton={true}
147159
showPollsButton={false} // !! the change from the alternate test
148160
showStickersButton={true}
149-
toggleButtonMenu={() => {}}
161+
{...mockProps}
150162
/>,
151163
true,
152164
);

0 commit comments

Comments
 (0)