@@ -20,38 +20,41 @@ const D2_SVG =
2020 '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1174 920"><rect width="1174" height="920"/></svg>' ;
2121
2222describe ( "ExpandedImageDialog" , ( ) => {
23- it ( "fits a markdown SVG without intrinsic size to the viewer" , async ( ) => {
24- const src = URL . createObjectURL ( new Blob ( [ D2_SVG ] , { type : "image/svg+xml" } ) ) ;
25- using _src = { [ Symbol . dispose ] : ( ) => URL . revokeObjectURL ( src ) } ;
26- await using screen = await render (
27- < ExpandedImageDialog
28- preview = { {
29- images : [
30- {
31- src,
32- name : "Pipeline" ,
33- actionsSource : {
34- kind : "image" ,
35- name : "Pipeline" ,
23+ it . each ( [ "/work/pipeline.svg" , "/work/diagram#v2.svg" , "/work/diagram?v2.svg" ] ) (
24+ "fits a markdown SVG without intrinsic size to the viewer: %s" ,
25+ async ( path ) => {
26+ const src = URL . createObjectURL ( new Blob ( [ D2_SVG ] , { type : "image/svg+xml" } ) ) ;
27+ using _src = { [ Symbol . dispose ] : ( ) => URL . revokeObjectURL ( src ) } ;
28+ await using screen = await render (
29+ < ExpandedImageDialog
30+ preview = { {
31+ images : [
32+ {
3633 src,
37- reference : { kind : "file" , path : "/work/pipeline.svg" } ,
34+ name : "Pipeline" ,
35+ actionsSource : {
36+ kind : "image" ,
37+ name : "Pipeline" ,
38+ src,
39+ reference : { kind : "file" , path } ,
40+ } ,
3841 } ,
39- } ,
40- ] ,
41- index : 0 ,
42- } }
43- onClose = { vi . fn ( ) }
44- /> ,
45- // The dialog renders no links and reads no route.
46- { router : false } ,
47- ) ;
42+ ] ,
43+ index : 0 ,
44+ } }
45+ onClose = { vi . fn ( ) }
46+ /> ,
47+ // The dialog renders no links and reads no route.
48+ { router : false } ,
49+ ) ;
4850
49- const viewer = screen . getByRole ( "region" , { name : "Pipeline, zoomable image" } ) ;
50- const availableWidth = window . innerWidth * 0.92 - ( window . innerWidth >= 640 ? 96 : 0 ) ;
51- await vi . waitFor ( ( ) =>
52- expect ( viewer . element ( ) . getBoundingClientRect ( ) . width ) . toBeCloseTo ( availableWidth , 0 ) ,
53- ) ;
54- } ) ;
51+ const viewer = screen . getByRole ( "region" , { name : "Pipeline, zoomable image" } ) ;
52+ const availableWidth = window . innerWidth * 0.92 - ( window . innerWidth >= 640 ? 96 : 0 ) ;
53+ await vi . waitFor ( ( ) =>
54+ expect ( viewer . element ( ) . getBoundingClientRect ( ) . width ) . toBeCloseTo ( availableWidth , 0 ) ,
55+ ) ;
56+ } ,
57+ ) ;
5558
5659 it ( "Escape closes a popup opened inside the dialog before the dialog" , async ( ) => {
5760 const onClose = vi . fn ( ) ;
0 commit comments