Step 8.6: Fix TS issues introduced by using imports

This commit is contained in:
Travis Ralston 2022-03-24 20:11:56 -06:00
parent 9a75acba17
commit b2b818a780
5 changed files with 71 additions and 6 deletions

View file

@ -36,6 +36,7 @@ describe("DateSeparator", () => {
const defaultProps = {
ts: nowMs,
now,
roomId: "!unused:example.org",
};
const RealDate = global.Date;
class MockDate extends Date {

View file

@ -1072,6 +1072,14 @@ function newMPollBodyFromEvent(
}
}
}
// We don't use any of these props, but they're required.
highlightLink="unused"
highlights={[]}
mediaEventHelper={null}
onHeightChanged={() => {}}
onMessageAllowed={() => {}}
permalinkCreator={null}
/>, {
wrappingComponent: MatrixClientContext.Provider,
wrappingComponentProps: {

View file

@ -3,6 +3,7 @@
exports[`DateSeparator renders the date separator correctly 1`] = `
<DateSeparator
now="2021-12-17T08:09:00.000Z"
roomId="!unused:example.org"
ts={1639728540000}
>
<h2
@ -29,6 +30,7 @@ exports[`DateSeparator renders the date separator correctly 1`] = `
exports[`DateSeparator when feature_jump_to_date is enabled renders the date separator correctly 1`] = `
<DateSeparator
now="2021-12-17T08:09:00.000Z"
roomId="!unused:example.org"
ts={1639728540000}
>
<h2

View file

@ -3,6 +3,9 @@
exports[`MPollBody renders a finished poll 1`] = `
<MPollBody
getRelationsForEvent={[Function]}
highlightLink="unused"
highlights={Array []}
mediaEventHelper={null}
mxEvent={
Object {
"content": Object {
@ -41,6 +44,9 @@ exports[`MPollBody renders a finished poll 1`] = `
"type": "org.matrix.msc3381.poll.start",
}
}
onHeightChanged={[Function]}
onMessageAllowed={[Function]}
permalinkCreator={null}
>
<div
className="mx_MPollBody"
@ -312,6 +318,9 @@ exports[`MPollBody renders a finished poll 1`] = `
exports[`MPollBody renders a finished poll with multiple winners 1`] = `
<MPollBody
getRelationsForEvent={[Function]}
highlightLink="unused"
highlights={Array []}
mediaEventHelper={null}
mxEvent={
Object {
"content": Object {
@ -350,6 +359,9 @@ exports[`MPollBody renders a finished poll with multiple winners 1`] = `
"type": "org.matrix.msc3381.poll.start",
}
}
onHeightChanged={[Function]}
onMessageAllowed={[Function]}
permalinkCreator={null}
>
<div
className="mx_MPollBody"
@ -621,6 +633,9 @@ exports[`MPollBody renders a finished poll with multiple winners 1`] = `
exports[`MPollBody renders a finished poll with no votes 1`] = `
<MPollBody
getRelationsForEvent={[Function]}
highlightLink="unused"
highlights={Array []}
mediaEventHelper={null}
mxEvent={
Object {
"content": Object {
@ -659,6 +674,9 @@ exports[`MPollBody renders a finished poll with no votes 1`] = `
"type": "org.matrix.msc3381.poll.start",
}
}
onHeightChanged={[Function]}
onMessageAllowed={[Function]}
permalinkCreator={null}
>
<div
className="mx_MPollBody"
@ -930,6 +948,9 @@ exports[`MPollBody renders a finished poll with no votes 1`] = `
exports[`MPollBody renders a poll that I have not voted in 1`] = `
<MPollBody
getRelationsForEvent={[Function]}
highlightLink="unused"
highlights={Array []}
mediaEventHelper={null}
mxEvent={
Object {
"content": Object {
@ -968,6 +989,9 @@ exports[`MPollBody renders a poll that I have not voted in 1`] = `
"type": "org.matrix.msc3381.poll.start",
}
}
onHeightChanged={[Function]}
onMessageAllowed={[Function]}
permalinkCreator={null}
>
<div
className="mx_MPollBody"
@ -1339,6 +1363,9 @@ exports[`MPollBody renders a poll that I have not voted in 1`] = `
exports[`MPollBody renders a poll with local, non-local and invalid votes 1`] = `
<MPollBody
getRelationsForEvent={[Function]}
highlightLink="unused"
highlights={Array []}
mediaEventHelper={null}
mxEvent={
Object {
"content": Object {
@ -1377,6 +1404,9 @@ exports[`MPollBody renders a poll with local, non-local and invalid votes 1`] =
"type": "org.matrix.msc3381.poll.start",
}
}
onHeightChanged={[Function]}
onMessageAllowed={[Function]}
permalinkCreator={null}
>
<div
className="mx_MPollBody"
@ -1756,6 +1786,9 @@ exports[`MPollBody renders a poll with local, non-local and invalid votes 1`] =
exports[`MPollBody renders a poll with no votes 1`] = `
<MPollBody
getRelationsForEvent={[Function]}
highlightLink="unused"
highlights={Array []}
mediaEventHelper={null}
mxEvent={
Object {
"content": Object {
@ -1794,6 +1827,9 @@ exports[`MPollBody renders a poll with no votes 1`] = `
"type": "org.matrix.msc3381.poll.start",
}
}
onHeightChanged={[Function]}
onMessageAllowed={[Function]}
permalinkCreator={null}
>
<div
className="mx_MPollBody"
@ -2165,6 +2201,9 @@ exports[`MPollBody renders a poll with no votes 1`] = `
exports[`MPollBody renders a poll with only non-local votes 1`] = `
<MPollBody
getRelationsForEvent={[Function]}
highlightLink="unused"
highlights={Array []}
mediaEventHelper={null}
mxEvent={
Object {
"content": Object {
@ -2203,6 +2242,9 @@ exports[`MPollBody renders a poll with only non-local votes 1`] = `
"type": "org.matrix.msc3381.poll.start",
}
}
onHeightChanged={[Function]}
onMessageAllowed={[Function]}
permalinkCreator={null}
>
<div
className="mx_MPollBody"

View file

@ -27,6 +27,18 @@ import { IRoomState } from "../../../../src/components/structures/RoomView";
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
import MessageComposerButtons from "../../../../src/components/views/rooms/MessageComposerButtons";
// @ts-ignore - we're deliberately not implementing the whole interface here, but
// can't use Partial<> for types because it'll annoy TS more than it helps.
const mockProps: React.ComponentProps<typeof MessageComposerButtons> = {
addEmoji: () => false,
haveRecording: false,
isStickerPickerOpen: false,
menuPosition: null,
onRecordStartEndClick: () => {},
setStickerPickerOpen: () => {},
toggleButtonMenu: () => {},
};
describe("MessageComposerButtons", () => {
it("Renders emoji and upload buttons in wide mode", () => {
const buttons = wrapAndRender(
@ -35,7 +47,7 @@ describe("MessageComposerButtons", () => {
showLocationButton={true}
showPollsButton={true}
showStickersButton={true}
toggleButtonMenu={() => {}}
{...mockProps}
/>,
false,
);
@ -54,7 +66,7 @@ describe("MessageComposerButtons", () => {
showLocationButton={true}
showPollsButton={true}
showStickersButton={true}
toggleButtonMenu={() => {}}
{...mockProps}
/>,
false,
);
@ -79,7 +91,7 @@ describe("MessageComposerButtons", () => {
showLocationButton={true}
showPollsButton={true}
showStickersButton={true}
toggleButtonMenu={() => {}}
{...mockProps}
/>,
true,
);
@ -97,7 +109,7 @@ describe("MessageComposerButtons", () => {
showLocationButton={true}
showPollsButton={true}
showStickersButton={true}
toggleButtonMenu={() => {}}
{...mockProps}
/>,
true,
);
@ -122,7 +134,7 @@ describe("MessageComposerButtons", () => {
showLocationButton={true}
showPollsButton={true}
showStickersButton={true}
toggleButtonMenu={() => {}}
{...mockProps}
/>,
true,
);
@ -146,7 +158,7 @@ describe("MessageComposerButtons", () => {
showLocationButton={true}
showPollsButton={false} // !! the change from the alternate test
showStickersButton={true}
toggleButtonMenu={() => {}}
{...mockProps}
/>,
true,
);