11import { fireEvent , render } from "@testing-library/react" ;
22import { describe , expect , it } from "vitest" ;
3- import { Streamdown , StreamdownContext } from "../index" ;
3+ import { Streamdown } from "../index" ;
44
55const markdownWithTable = `
66| Name | Age |
@@ -11,9 +11,7 @@ const markdownWithTable = `
1111
1212describe ( "TableFullscreenButton" , ( ) => {
1313 it ( "should render fullscreen button when controls are enabled" , ( ) => {
14- const { container } = render (
15- < Streamdown > { markdownWithTable } </ Streamdown >
16- ) ;
14+ const { container } = render ( < Streamdown > { markdownWithTable } </ Streamdown > ) ;
1715
1816 const btn = container . querySelector ( 'button[title="View fullscreen"]' ) ;
1917 expect ( btn ) . toBeTruthy ( ) ;
@@ -40,9 +38,7 @@ describe("TableFullscreenButton", () => {
4038 } ) ;
4139
4240 it ( "should open fullscreen overlay on click" , ( ) => {
43- const { container } = render (
44- < Streamdown > { markdownWithTable } </ Streamdown >
45- ) ;
41+ const { container } = render ( < Streamdown > { markdownWithTable } </ Streamdown > ) ;
4642
4743 const btn = container . querySelector (
4844 'button[title="View fullscreen"]'
@@ -58,9 +54,7 @@ describe("TableFullscreenButton", () => {
5854 } ) ;
5955
6056 it ( "should close fullscreen overlay on close button click" , ( ) => {
61- const { container } = render (
62- < Streamdown > { markdownWithTable } </ Streamdown >
63- ) ;
57+ const { container } = render ( < Streamdown > { markdownWithTable } </ Streamdown > ) ;
6458
6559 const btn = container . querySelector (
6660 'button[title="View fullscreen"]'
@@ -81,9 +75,7 @@ describe("TableFullscreenButton", () => {
8175 } ) ;
8276
8377 it ( "should close fullscreen overlay on Escape key" , ( ) => {
84- const { container } = render (
85- < Streamdown > { markdownWithTable } </ Streamdown >
86- ) ;
78+ const { container } = render ( < Streamdown > { markdownWithTable } </ Streamdown > ) ;
8779
8880 const btn = container . querySelector (
8981 'button[title="View fullscreen"]'
@@ -102,9 +94,7 @@ describe("TableFullscreenButton", () => {
10294 } ) ;
10395
10496 it ( "should lock body scroll when fullscreen is open" , ( ) => {
105- const { container } = render (
106- < Streamdown > { markdownWithTable } </ Streamdown >
107- ) ;
97+ const { container } = render ( < Streamdown > { markdownWithTable } </ Streamdown > ) ;
10898
10999 const btn = container . querySelector (
110100 'button[title="View fullscreen"]'
@@ -134,9 +124,7 @@ describe("TableFullscreenButton", () => {
134124 } ) ;
135125
136126 it ( "should render table content inside fullscreen overlay" , ( ) => {
137- const { container } = render (
138- < Streamdown > { markdownWithTable } </ Streamdown >
139- ) ;
127+ const { container } = render ( < Streamdown > { markdownWithTable } </ Streamdown > ) ;
140128
141129 const btn = container . querySelector (
142130 'button[title="View fullscreen"]'
@@ -151,9 +139,7 @@ describe("TableFullscreenButton", () => {
151139 } ) ;
152140
153141 it ( "should show copy and download controls in fullscreen" , ( ) => {
154- const { container } = render (
155- < Streamdown > { markdownWithTable } </ Streamdown >
156- ) ;
142+ const { container } = render ( < Streamdown > { markdownWithTable } </ Streamdown > ) ;
157143
158144 const btn = container . querySelector (
159145 'button[title="View fullscreen"]'
@@ -172,9 +158,7 @@ describe("TableFullscreenButton", () => {
172158 } ) ;
173159
174160 it ( "should not close fullscreen when clicking controls inside overlay" , ( ) => {
175- const { container } = render (
176- < Streamdown > { markdownWithTable } </ Streamdown >
177- ) ;
161+ const { container } = render ( < Streamdown > { markdownWithTable } </ Streamdown > ) ;
178162
179163 const btn = container . querySelector (
180164 'button[title="View fullscreen"]'
@@ -198,9 +182,7 @@ describe("TableFullscreenButton", () => {
198182 } ) ;
199183
200184 it ( "should not close fullscreen when clicking table content" , ( ) => {
201- const { container } = render (
202- < Streamdown > { markdownWithTable } </ Streamdown >
203- ) ;
185+ const { container } = render ( < Streamdown > { markdownWithTable } </ Streamdown > ) ;
204186
205187 const btn = container . querySelector (
206188 'button[title="View fullscreen"]'
@@ -222,9 +204,7 @@ describe("TableFullscreenButton", () => {
222204 } ) ;
223205
224206 it ( "should close fullscreen overlay on backdrop click" , ( ) => {
225- const { container } = render (
226- < Streamdown > { markdownWithTable } </ Streamdown >
227- ) ;
207+ const { container } = render ( < Streamdown > { markdownWithTable } </ Streamdown > ) ;
228208
229209 const btn = container . querySelector (
230210 'button[title="View fullscreen"]'
@@ -236,17 +216,17 @@ describe("TableFullscreenButton", () => {
236216 ) ;
237217 expect ( overlay ) . toBeTruthy ( ) ;
238218
239- fireEvent . click ( overlay ! ) ;
219+ if ( overlay ) {
220+ fireEvent . click ( overlay ) ;
221+ }
240222
241223 expect (
242224 document . querySelector ( '[data-streamdown="table-fullscreen"]' )
243225 ) . toBeFalsy ( ) ;
244226 } ) ;
245227
246228 it ( "should have aria attributes on fullscreen overlay" , ( ) => {
247- const { container } = render (
248- < Streamdown > { markdownWithTable } </ Streamdown >
249- ) ;
229+ const { container } = render ( < Streamdown > { markdownWithTable } </ Streamdown > ) ;
250230
251231 const btn = container . querySelector (
252232 'button[title="View fullscreen"]'
0 commit comments