11import React from "react" ;
2- import { render , screen , fireEvent } from "@testing-library/react" ;
2+ import { render , screen } from "@testing-library/react" ;
3+ import userEvent from "@testing-library/user-event" ;
34
45import { Transcript } from "./transcript" ;
56
@@ -25,34 +26,34 @@ describe("<Transcript />", () => {
2526 expect ( screen . getByText ( "Sample transcript text" ) ) . not . toBeVisible ( ) ;
2627 } ) ;
2728
28- it ( "should toggle open when clicking the summary" , ( ) => {
29+ it ( "should toggle open when clicking the summary" , async ( ) => {
2930 render ( < Transcript { ...baseProps } /> ) ;
3031
3132 const summary = screen . getByText ( "Transcript" ) ;
32- fireEvent . click ( summary ) ;
33+ await userEvent . click ( summary ) ;
3334
3435 const details = screen . getByRole ( "group" ) ;
3536 expect ( details ) . toHaveAttribute ( "open" ) ;
3637 expect ( screen . getByText ( "Sample transcript text" ) ) . toBeVisible ( ) ;
3738 } ) ;
3839
39- it ( "should filter out empty lines" , ( ) => {
40+ it ( "should filter out empty lines" , async ( ) => {
4041 const transcript = `Hello\n\n\nWorld\n \n` ;
4142 render ( < Transcript transcript = { transcript } /> ) ;
4243
43- fireEvent . click ( screen . getByText ( "Transcript" ) ) ;
44+ await userEvent . click ( screen . getByText ( "Transcript" ) ) ;
4445
4546 const paragraphs = screen . getAllByText ( / H e l l o | W o r l d / ) ;
4647 expect ( paragraphs ) . toHaveLength ( 2 ) ;
4748 expect ( paragraphs [ 0 ] ) . toHaveTextContent ( "Hello" ) ;
4849 expect ( paragraphs [ 1 ] ) . toHaveTextContent ( "World" ) ;
4950 } ) ;
5051
51- it ( "should render speaker names in bold" , ( ) => {
52+ it ( "should render speaker names in bold" , async ( ) => {
5253 const transcript = `Tom: Hello there!\nMaria: Hi Tom, how are you?` ;
5354 render ( < Transcript transcript = { transcript } /> ) ;
5455
55- fireEvent . click ( screen . getByText ( "Transcript" ) ) ;
56+ await userEvent . click ( screen . getByText ( "Transcript" ) ) ;
5657
5758 const tomElement = screen . getByText ( "Tom:" ) ;
5859 const mariaElement = screen . getByText ( "Maria:" ) ;
0 commit comments