fix tests

pull/21833/head
Michael Telatynski 2020-11-05 16:27:41 +00:00
parent 81f1e1d8d7
commit 54e41b5f32
5 changed files with 12 additions and 8 deletions

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import React, {useContext} from 'react';
import React, {forwardRef, useContext} from 'react';
import {MatrixEvent} from "matrix-js-sdk/src/models/event";
import { _t } from '../../../languageHandler';
@ -27,7 +27,7 @@ interface IProps {
mxEvent: MatrixEvent;
}
const EncryptionEvent: React.FC<IProps> = ({mxEvent}) => {
const EncryptionEvent = forwardRef<HTMLDivElement, IProps>(({mxEvent}, ref) => {
const cli = useContext(MatrixClientContext);
const roomId = mxEvent.getRoomId();
const isRoomEncrypted = MatrixClientPeg.get().isRoomEncrypted(roomId);
@ -61,7 +61,8 @@ const EncryptionEvent: React.FC<IProps> = ({mxEvent}) => {
className="mx_cryptoEvent mx_cryptoEvent_icon mx_cryptoEvent_icon_warning"
title={_t("Encryption not enabled")}
subtitle={_t("The encryption used by this room isn't supported.")}
ref={ref}
/>;
}
});
export default EncryptionEvent;

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import React, {ReactNode} from "react";
import React, {forwardRef, ReactNode} from "react";
import classNames from "classnames";
interface IProps {
@ -23,12 +23,12 @@ interface IProps {
subtitle?: ReactNode;
}
const EventTileBubble: React.FC<IProps> = ({ className, title, subtitle, children }) => {
return <div className={classNames("mx_EventTileBubble", className)}>
const EventTileBubble = forwardRef<HTMLDivElement, IProps>(({ className, title, subtitle, children }, ref) => {
return <div className={classNames("mx_EventTileBubble", className)} ref={ref}>
<div className="mx_EventTileBubble_title">{ title }</div>
{ subtitle && <div className="mx_EventTileBubble_subtitle">{ subtitle }</div> }
{ children }
</div>;
};
});
export default EventTileBubble;

View File

@ -29,7 +29,6 @@ const RoomContext = createContext<IState>({
guestsCanJoin: false,
canPeek: false,
showApps: false,
isAlone: false,
isPeeking: false,
showingPinned: false,
showReadReceipts: true,

View File

@ -38,6 +38,7 @@ import { configure, mount } from "enzyme";
import Velocity from 'velocity-animate';
import MatrixClientContext from "../../../src/contexts/MatrixClientContext";
import RoomContext from "../../../src/contexts/RoomContext";
import DMRoomMap from "../../../src/utils/DMRoomMap";
configure({ adapter: new Adapter() });
@ -79,6 +80,8 @@ describe('MessagePanel', function() {
// complete without this even if we mock the clock and tick it
// what should be the correct amount of time).
Velocity.mock = true;
DMRoomMap.makeShared();
});
afterEach(function() {

View File

@ -242,6 +242,7 @@ export function mkStubRoom(roomId = null) {
setBlacklistUnverifiedDevices: jest.fn(),
on: jest.fn(),
removeListener: jest.fn(),
getDMInviter: jest.fn(),
};
}