fix tests

This commit is contained in:
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. 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 {MatrixEvent} from "matrix-js-sdk/src/models/event";
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
@ -27,7 +27,7 @@ interface IProps {
mxEvent: MatrixEvent; mxEvent: MatrixEvent;
} }
const EncryptionEvent: React.FC<IProps> = ({mxEvent}) => { const EncryptionEvent = forwardRef<HTMLDivElement, IProps>(({mxEvent}, ref) => {
const cli = useContext(MatrixClientContext); const cli = useContext(MatrixClientContext);
const roomId = mxEvent.getRoomId(); const roomId = mxEvent.getRoomId();
const isRoomEncrypted = MatrixClientPeg.get().isRoomEncrypted(roomId); 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" className="mx_cryptoEvent mx_cryptoEvent_icon mx_cryptoEvent_icon_warning"
title={_t("Encryption not enabled")} title={_t("Encryption not enabled")}
subtitle={_t("The encryption used by this room isn't supported.")} subtitle={_t("The encryption used by this room isn't supported.")}
ref={ref}
/>; />;
} });
export default EncryptionEvent; export default EncryptionEvent;

View file

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

View file

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

View file

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

View file

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