@@ -1461,6 +1461,98 @@ describe("OdtDocument", () => {
14611461 expect ( content ) . toContain ( 'xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"' ) ;
14621462 expect ( content ) . toContain ( 'xmlns:xlink="http://www.w3.org/1999/xlink"' ) ;
14631463 } ) ;
1464+
1465+ it ( "should emit svg:title when alt is provided" , async ( ) => {
1466+ const doc = new OdtDocument ( ) ;
1467+ doc . addImage ( TEST_PNG , {
1468+ width : "10cm" ,
1469+ height : "6cm" ,
1470+ mimeType : "image/png" ,
1471+ alt : "Company logo" ,
1472+ } ) ;
1473+
1474+ const content = await getContentXml ( doc ) ;
1475+ expect ( content ) . toContain ( "<svg:title>Company logo</svg:title>" ) ;
1476+ expect ( content ) . not . toContain ( "svg:desc" ) ;
1477+ } ) ;
1478+
1479+ it ( "should emit svg:desc when description is provided" , async ( ) => {
1480+ const doc = new OdtDocument ( ) ;
1481+ doc . addImage ( TEST_PNG , {
1482+ width : "10cm" ,
1483+ height : "6cm" ,
1484+ mimeType : "image/png" ,
1485+ description : "A photograph of the office building" ,
1486+ } ) ;
1487+
1488+ const content = await getContentXml ( doc ) ;
1489+ expect ( content ) . toContain ( "<svg:desc>A photograph of the office building</svg:desc>" ) ;
1490+ expect ( content ) . not . toContain ( "svg:title" ) ;
1491+ } ) ;
1492+
1493+ it ( "should emit both svg:title and svg:desc before draw:image when both are provided" , async ( ) => {
1494+ const doc = new OdtDocument ( ) ;
1495+ doc . addImage ( TEST_PNG , {
1496+ width : "2cm" ,
1497+ height : "0.5cm" ,
1498+ mimeType : "image/png" ,
1499+ alt : "LaTeX: \\frac{1}{2}" ,
1500+ description : "$\\frac{1}{2}$" ,
1501+ } ) ;
1502+
1503+ const content = await getContentXml ( doc ) ;
1504+ expect ( content ) . toContain ( "<svg:title>LaTeX: \\frac{1}{2}</svg:title>" ) ;
1505+ expect ( content ) . toContain ( "<svg:desc>$\\frac{1}{2}$</svg:desc>" ) ;
1506+ const titlePos = content . indexOf ( "<svg:title>" ) ;
1507+ const descPos = content . indexOf ( "<svg:desc>" ) ;
1508+ const imagePos = content . indexOf ( "draw:image" ) ;
1509+ expect ( titlePos ) . toBeLessThan ( descPos ) ;
1510+ expect ( descPos ) . toBeLessThan ( imagePos ) ;
1511+ } ) ;
1512+
1513+ it ( "should use caller-supplied name as draw:name" , async ( ) => {
1514+ const doc = new OdtDocument ( ) ;
1515+ doc . addImage ( TEST_PNG , {
1516+ width : "2cm" ,
1517+ height : "0.5cm" ,
1518+ mimeType : "image/png" ,
1519+ name : "formula-1" ,
1520+ } ) ;
1521+
1522+ const content = await getContentXml ( doc ) ;
1523+ expect ( content ) . toContain ( 'draw:name="formula-1"' ) ;
1524+ expect ( content ) . not . toContain ( 'draw:name="Image1"' ) ;
1525+ } ) ;
1526+
1527+ it ( "should support anchor type page" , async ( ) => {
1528+ const doc = new OdtDocument ( ) ;
1529+ doc . addImage ( TEST_PNG , {
1530+ width : "10cm" ,
1531+ height : "6cm" ,
1532+ mimeType : "image/png" ,
1533+ anchor : "page" ,
1534+ } ) ;
1535+
1536+ const content = await getContentXml ( doc ) ;
1537+ expect ( content ) . toContain ( 'text:anchor-type="page"' ) ;
1538+ } ) ;
1539+
1540+ it ( "should emit svg:title with alt in inline paragraph image" , async ( ) => {
1541+ const doc = new OdtDocument ( ) ;
1542+ doc . addParagraph ( ( p ) => {
1543+ p . addImage ( TEST_PNG , {
1544+ width : "2cm" ,
1545+ height : "0.5cm" ,
1546+ mimeType : "image/png" ,
1547+ alt : "LaTeX: \\frac{1}{2}" ,
1548+ description : "$\\frac{1}{2}$" ,
1549+ } ) ;
1550+ } ) ;
1551+
1552+ const content = await getContentXml ( doc ) ;
1553+ expect ( content ) . toContain ( "<svg:title>LaTeX: \\frac{1}{2}</svg:title>" ) ;
1554+ expect ( content ) . toContain ( "<svg:desc>$\\frac{1}{2}$</svg:desc>" ) ;
1555+ } ) ;
14641556 } ) ;
14651557
14661558 // ─── Repair Plan: Generation Side Fixes ─────────────────────────────
0 commit comments