@@ -44,10 +44,20 @@ describe("<RoomCreate />", () => {
4444 } ,
4545 event_id : "$create" ,
4646 } ) ;
47+ const createEventWithoutPredecessor = new MatrixEvent ( {
48+ type : EventType . RoomCreate ,
49+ state_key : "" ,
50+ sender : userId ,
51+ room_id : roomId ,
52+ content : { } ,
53+ event_id : "$create" ,
54+ } ) ;
4755 stubClient ( ) ;
4856 const client = mocked ( MatrixClientPeg . get ( ) ) ;
4957 const room = new Room ( roomId , client , userId ) ;
5058 upsertRoomStateEvents ( room , [ createEvent ] ) ;
59+ const roomNoPredecessors = new Room ( roomId , client , userId ) ;
60+ upsertRoomStateEvents ( roomNoPredecessors , [ createEventWithoutPredecessor ] ) ;
5161
5262 beforeEach ( ( ) => {
5363 jest . clearAllMocks ( ) ;
@@ -62,7 +72,7 @@ describe("<RoomCreate />", () => {
6272 jest . spyOn ( SettingsStore , "setValue" ) . mockRestore ( ) ;
6373 } ) ;
6474
65- function renderRoomCreate ( ) {
75+ function renderRoomCreate ( room : Room ) {
6676 return render (
6777 < RoomContext . Provider value = { getRoomContext ( room , { } ) } >
6878 < RoomCreate mxEvent = { createEvent } />
@@ -71,20 +81,25 @@ describe("<RoomCreate />", () => {
7181 }
7282
7383 it ( "Renders as expected" , ( ) => {
74- const roomCreate = renderRoomCreate ( ) ;
84+ const roomCreate = renderRoomCreate ( room ) ;
7585 expect ( roomCreate . asFragment ( ) ) . toMatchSnapshot ( ) ;
7686 } ) ;
7787
7888 it ( "Links to the old version of the room" , ( ) => {
79- renderRoomCreate ( ) ;
89+ renderRoomCreate ( room ) ;
8090 expect ( screen . getByText ( "Click here to see older messages." ) ) . toHaveAttribute (
8191 "href" ,
8292 "https://matrix.to/#/old_room_id/tombstone_event_id" ,
8393 ) ;
8494 } ) ;
8595
96+ it ( "Shows an empty div if there is no predecessor" , ( ) => {
97+ renderRoomCreate ( roomNoPredecessors ) ;
98+ expect ( screen . queryByText ( "Click here to see older messages." , { exact : false } ) ) . toBeNull ( ) ;
99+ } ) ;
100+
86101 it ( "Opens the old room on click" , async ( ) => {
87- renderRoomCreate ( ) ;
102+ renderRoomCreate ( room ) ;
88103 const link = screen . getByText ( "Click here to see older messages." ) ;
89104
90105 await act ( ( ) => userEvent . click ( link ) ) ;
0 commit comments