@@ -57,6 +57,21 @@ jest.mock("../../../../../src/utils/EventRenderingUtils", () => ({
5757const mockGetEventDisplayInfo = jest . requireMock ( "../../../../../src/utils/EventRenderingUtils" )
5858 . getEventDisplayInfo as jest . Mock ;
5959
60+ function createTimestampedViewModel (
61+ room : Room ,
62+ createViewModel : ( overrides ?: Partial < EventTileViewModelProps > ) => EventTileViewModel ,
63+ ) : EventTileViewModel {
64+ const timestampedEvent = mkMessage ( {
65+ room : room . roomId ,
66+ user : "@alice:example.org" ,
67+ msg : "timestamped" ,
68+ event : true ,
69+ ts : 123 ,
70+ } ) ;
71+
72+ return createViewModel ( { mxEvent : timestampedEvent } ) ;
73+ }
74+
6075describe ( "EventTileViewModel" , ( ) => {
6176 const ROOM_ID = "!roomId:example.org" ;
6277 let mxEvent : MatrixEvent ;
@@ -455,20 +470,8 @@ describe("EventTileViewModel", () => {
455470 } ) ;
456471
457472 describe ( "interaction state" , ( ) => {
458- function createTimestampedViewModel ( ) : EventTileViewModel {
459- const timestampedEvent = mkMessage ( {
460- room : room . roomId ,
461- user : "@alice:example.org" ,
462- msg : "timestamped" ,
463- event : true ,
464- ts : 123 ,
465- } ) ;
466-
467- return createViewModel ( { mxEvent : timestampedEvent } ) ;
468- }
469-
470473 it ( "shows and hides timestamps when hover changes" , ( ) => {
471- const vm = createTimestampedViewModel ( ) ;
474+ const vm = createTimestampedViewModel ( room , createViewModel ) ;
472475
473476 expect ( vm . getSnapshot ( ) . showTimestamp ) . toBe ( false ) ;
474477 expect ( vm . getSnapshot ( ) . shouldRenderActionBar ) . toBe ( false ) ;
@@ -485,7 +488,7 @@ describe("EventTileViewModel", () => {
485488 } ) ;
486489
487490 it ( "shows timestamps when focus enters the tile" , ( ) => {
488- const vm = createTimestampedViewModel ( ) ;
491+ const vm = createTimestampedViewModel ( room , createViewModel ) ;
489492
490493 vm . onFocusEnter ( false ) ;
491494
@@ -494,7 +497,7 @@ describe("EventTileViewModel", () => {
494497 } ) ;
495498
496499 it ( "shows the action bar when focus enters via keyboard" , ( ) => {
497- const vm = createTimestampedViewModel ( ) ;
500+ const vm = createTimestampedViewModel ( room , createViewModel ) ;
498501
499502 vm . onFocusEnter ( true ) ;
500503
@@ -505,7 +508,7 @@ describe("EventTileViewModel", () => {
505508 } ) ;
506509
507510 it ( "shows timestamps when the action bar is focused" , ( ) => {
508- const vm = createTimestampedViewModel ( ) ;
511+ const vm = createTimestampedViewModel ( room , createViewModel ) ;
509512
510513 vm . onActionBarFocusChange ( true , false ) ;
511514
@@ -515,7 +518,7 @@ describe("EventTileViewModel", () => {
515518 } ) ;
516519
517520 it ( "keeps action bar focus in sync with the context menu state" , ( ) => {
518- const vm = createTimestampedViewModel ( ) ;
521+ const vm = createTimestampedViewModel ( room , createViewModel ) ;
519522
520523 vm . onContextMenuOpen ( ) ;
521524
@@ -533,7 +536,7 @@ describe("EventTileViewModel", () => {
533536 } ) ;
534537
535538 it ( "preserves keyboard-triggered action bar visibility when the context menu closes" , ( ) => {
536- const vm = createTimestampedViewModel ( ) ;
539+ const vm = createTimestampedViewModel ( room , createViewModel ) ;
537540
538541 vm . onFocusEnter ( true ) ;
539542 vm . onContextMenuOpen ( ) ;
@@ -546,7 +549,7 @@ describe("EventTileViewModel", () => {
546549 } ) ;
547550
548551 it ( "applies focus enter and leave as a single VM transition" , ( ) => {
549- const vm = createTimestampedViewModel ( ) ;
552+ const vm = createTimestampedViewModel ( room , createViewModel ) ;
550553
551554 vm . onFocusEnter ( true ) ;
552555
@@ -562,7 +565,7 @@ describe("EventTileViewModel", () => {
562565 } ) ;
563566
564567 it ( "resets hover when action bar focus is lost through the VM helper" , ( ) => {
565- const vm = createTimestampedViewModel ( ) ;
568+ const vm = createTimestampedViewModel ( room , createViewModel ) ;
566569
567570 vm . setHover ( true ) ;
568571 vm . onActionBarFocusChange ( true , true ) ;
@@ -578,7 +581,7 @@ describe("EventTileViewModel", () => {
578581 } ) ;
579582
580583 it ( "opens and closes the context menu through VM helpers" , ( ) => {
581- const vm = createTimestampedViewModel ( ) ;
584+ const vm = createTimestampedViewModel ( room , createViewModel ) ;
582585
583586 vm . onContextMenuOpen ( ) ;
584587
@@ -594,7 +597,7 @@ describe("EventTileViewModel", () => {
594597 } ) ;
595598
596599 it ( "stores and clears context menu state through VM command helpers" , ( ) => {
597- const vm = createTimestampedViewModel ( ) ;
600+ const vm = createTimestampedViewModel ( room , createViewModel ) ;
598601 const target = document . createElement ( "div" ) ;
599602
600603 vm . openContextMenu ( {
0 commit comments