@@ -9,17 +9,15 @@ import { render } from "@testing-library/react";
99import { expect , test } from "vitest" ;
1010import { TooltipProvider } from "@vector-im/compound-web" ;
1111import { act , ReactNode } from "react" ;
12+ import { afterEach } from "node:test" ;
1213
1314import {
1415 MockRoom ,
1516 MockRTCSession ,
1617 TestReactionsWrapper ,
1718} from "../utils/testReactions" ;
18- import {
19- showReactions ,
20- } from "../settings/settings" ;
19+ import { showReactions } from "../settings/settings" ;
2120import { ReactionsOverlay } from "./ReactionsOverlay" ;
22- import { afterEach } from "node:test" ;
2321import { ReactionSet } from "../reactions" ;
2422
2523const memberUserIdAlice = "@alice:example.org" ;
@@ -49,7 +47,6 @@ function TestComponent({
4947 ) ;
5048}
5149
52-
5350afterEach ( ( ) => {
5451 showReactions . setValue ( showReactions . defaultValue ) ;
5552} ) ;
@@ -61,51 +58,51 @@ test("defaults to showing no reactions", () => {
6158 membership ,
6259 ) ;
6360 const { container } = render ( < TestComponent rtcSession = { rtcSession } /> ) ;
64- expect ( container . getElementsByTagName ( "span" ) ) . toHaveLength (
65- 0
66- ) ;
61+ expect ( container . getElementsByTagName ( "span" ) ) . toHaveLength ( 0 ) ;
6762} ) ;
6863
6964test ( "shows a reaction when sent" , ( ) => {
7065 showReactions . setValue ( true ) ;
7166 const reaction = ReactionSet [ 0 ] ;
7267 const room = new MockRoom ( memberUserIdAlice ) ;
73- const rtcSession = new MockRTCSession (
74- room ,
75- membership ,
76- ) ;
68+ const rtcSession = new MockRTCSession ( room , membership ) ;
7769 const { getByRole } = render ( < TestComponent rtcSession = { rtcSession } /> ) ;
78- act ( ( ) => room . testSendReaction ( memberEventAlice , reaction , membership ) ) ;
79- const span = getByRole ( 'presentation' ) ;
80- expect ( getByRole ( 'presentation' ) ) . toBeTruthy ( ) ;
70+ act ( ( ) => {
71+ room . testSendReaction ( memberEventAlice , reaction , membership ) ;
72+ } ) ;
73+ const span = getByRole ( "presentation" ) ;
74+ expect ( getByRole ( "presentation" ) ) . toBeTruthy ( ) ;
8175 expect ( span . innerHTML ) . toEqual ( reaction . emoji ) ;
8276} ) ;
8377
8478test ( "shows two of the same reaction when sent" , ( ) => {
8579 showReactions . setValue ( true ) ;
80+ const reaction = ReactionSet [ 0 ] ;
8681 const room = new MockRoom ( memberUserIdAlice ) ;
87- const rtcSession = new MockRTCSession (
88- room ,
89- membership ,
90- ) ;
82+ const rtcSession = new MockRTCSession ( room , membership ) ;
9183 const { getAllByRole } = render ( < TestComponent rtcSession = { rtcSession } /> ) ;
92- act ( ( ) => room . testSendReaction ( memberEventAlice , ReactionSet [ 0 ] , membership ) ) ;
93- act ( ( ) => room . testSendReaction ( memberEventBob , ReactionSet [ 0 ] , membership ) ) ;
94- expect ( getAllByRole ( 'presentation' ) ) . toHaveLength ( 2 ) ;
84+ act ( ( ) => {
85+ room . testSendReaction ( memberEventAlice , reaction , membership ) ;
86+ } ) ;
87+ act ( ( ) => {
88+ room . testSendReaction ( memberEventBob , reaction , membership ) ;
89+ } ) ;
90+ expect ( getAllByRole ( "presentation" ) ) . toHaveLength ( 2 ) ;
9591} ) ;
9692
9793test ( "shows two different reactions when sent" , ( ) => {
9894 showReactions . setValue ( true ) ;
9995 const room = new MockRoom ( memberUserIdAlice ) ;
100- const rtcSession = new MockRTCSession (
101- room ,
102- membership ,
103- ) ;
96+ const rtcSession = new MockRTCSession ( room , membership ) ;
10497 const [ reactionA , reactionB ] = ReactionSet ;
10598 const { getAllByRole } = render ( < TestComponent rtcSession = { rtcSession } /> ) ;
106- act ( ( ) => room . testSendReaction ( memberEventAlice , reactionA , membership ) ) ;
107- act ( ( ) => room . testSendReaction ( memberEventBob , reactionB , membership ) ) ;
108- const [ reactionElementA , reactionElementB ] = getAllByRole ( 'presentation' ) ;
99+ act ( ( ) => {
100+ room . testSendReaction ( memberEventAlice , reactionA , membership ) ;
101+ } ) ;
102+ act ( ( ) => {
103+ room . testSendReaction ( memberEventBob , reactionB , membership ) ;
104+ } ) ;
105+ const [ reactionElementA , reactionElementB ] = getAllByRole ( "presentation" ) ;
109106 expect ( reactionElementA . innerHTML ) . toEqual ( reactionA . emoji ) ;
110107 expect ( reactionElementB . innerHTML ) . toEqual ( reactionB . emoji ) ;
111108} ) ;
@@ -114,13 +111,10 @@ test("hides reactions when reaction animations are disabled", () => {
114111 showReactions . setValue ( false ) ;
115112 const reaction = ReactionSet [ 0 ] ;
116113 const room = new MockRoom ( memberUserIdAlice ) ;
117- const rtcSession = new MockRTCSession (
118- room ,
119- membership ,
120- ) ;
121- act ( ( ) => room . testSendReaction ( memberEventAlice , reaction , membership ) ) ;
114+ const rtcSession = new MockRTCSession ( room , membership ) ;
115+ act ( ( ) => {
116+ room . testSendReaction ( memberEventAlice , reaction , membership ) ;
117+ } ) ;
122118 const { container } = render ( < TestComponent rtcSession = { rtcSession } /> ) ;
123- expect ( container . getElementsByTagName ( "span" ) ) . toHaveLength (
124- 0
125- ) ;
126- } ) ;
119+ expect ( container . getElementsByTagName ( "span" ) ) . toHaveLength ( 0 ) ;
120+ } ) ;
0 commit comments