@@ -15,7 +15,7 @@ limitations under the License.
1515*/
1616
1717import React from "react" ;
18- import { act , render , screen , waitFor } from "@testing-library/react" ;
18+ import { act , fireEvent , render , screen , waitFor } from "@testing-library/react" ;
1919import { EventType } from "matrix-js-sdk/src/@types/event" ;
2020import { MatrixClient , PendingEventOrdering } from "matrix-js-sdk/src/client" ;
2121import { MatrixEvent } from "matrix-js-sdk/src/models/event" ;
@@ -28,6 +28,10 @@ import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
2828import SettingsStore from "../../../../src/settings/SettingsStore" ;
2929import { getRoomContext , mkEvent , mkMessage , stubClient } from "../../../test-utils" ;
3030import { mkThread } from "../../../test-utils/threads" ;
31+ import RoomAvatar from "../../../../src/components/views/avatars/RoomAvatar" ;
32+ import DMRoomMap from "../../../../src/utils/DMRoomMap" ;
33+ import dis from "../../../../src/dispatcher/dispatcher" ;
34+ import { Action } from "../../../../src/dispatcher/actions" ;
3135
3236describe ( "EventTile" , ( ) => {
3337 const ROOM_ID = "!roomId:example.org" ;
@@ -154,4 +158,42 @@ describe("EventTile", () => {
154158 expect ( container . getElementsByClassName ( "mx_NotificationBadge_highlighted" ) ) . toHaveLength ( 1 ) ;
155159 } ) ;
156160 } ) ;
161+
162+ describe ( "EventTile in the right panel" , ( ) => {
163+ beforeAll ( ( ) => {
164+ const dmRoomMap : DMRoomMap = {
165+ getUserIdForRoomId : jest . fn ( ) ,
166+ } as unknown as DMRoomMap ;
167+ DMRoomMap . setShared ( dmRoomMap ) ;
168+ } ) ;
169+
170+ it ( "renders the room name for notifications" , ( ) => {
171+ const { container } = getComponent ( { } , TimelineRenderingType . Notification ) ;
172+ expect ( container . getElementsByClassName ( "mx_EventTile_details" ) [ 0 ] ) . toHaveTextContent (
173+ "@alice:example.org in !roomId:example.org" ,
174+ ) ;
175+ } ) ;
176+
177+ it ( "renders the sender for the thread list" , ( ) => {
178+ const { container } = getComponent ( { } , TimelineRenderingType . ThreadsList ) ;
179+ expect ( container . getElementsByClassName ( "mx_EventTile_details" ) [ 0 ] ) . toHaveTextContent ( "@alice:example.org" ) ;
180+ } ) ;
181+
182+ it . each ( [
183+ [ TimelineRenderingType . Notification , Action . ViewRoom ] ,
184+ [ TimelineRenderingType . ThreadsList , Action . ShowThread ] ,
185+ ] ) ( "type %s dispatches %s" , ( renderingType , action ) => {
186+ jest . spyOn ( dis , "dispatch" ) ;
187+
188+ const { container } = getComponent ( { } , renderingType ) ;
189+
190+ fireEvent . click ( container . querySelector ( "li" ) ) ;
191+
192+ expect ( dis . dispatch ) . toHaveBeenCalledWith (
193+ expect . objectContaining ( {
194+ action,
195+ } ) ,
196+ ) ;
197+ } ) ;
198+ } ) ;
157199} ) ;
0 commit comments