From 7abae173f67d7170728362cd69d2f6402a76e4db Mon Sep 17 00:00:00 2001 From: Luis Gallego Date: Thu, 30 Apr 2026 15:52:50 +0200 Subject: [PATCH] DEV-26740 Tests for cell borders and hyperlinks --- lib/components/document/test/Cell.test.ts | 47 +++++++++++++++++++ .../document/test/Hyperlink.test.ts | 32 ++++++------- 2 files changed, 63 insertions(+), 16 deletions(-) diff --git a/lib/components/document/test/Cell.test.ts b/lib/components/document/test/Cell.test.ts index 132920d..1a1b79b 100644 --- a/lib/components/document/test/Cell.test.ts +++ b/lib/components/document/test/Cell.test.ts @@ -188,3 +188,50 @@ describe('Cell - with colspan', () => { expect(originalCellWidths).toEqual(newCellWidths); }); }); + +describe('Cell - with borders', () => { + const tableNode = create(` + + + + + + + + + + + + + + + + `); + + it('cell width', async () => { + const fromNode = Table.fromNode(tableNode, emptyContext); + const toNode = await fromNode.toNode([]); + + const originalBorder = evaluateXPathToFirstNode( + `./descendant::Q{${NamespaceUri.w}}tcBorders`, + tableNode + ); + const newBorder = evaluateXPathToFirstNode( + `./descendant::Q{${NamespaceUri.w}}tcBorders`, + toNode + ); + + expect(originalBorder?.getAttributeNS(NamespaceUri.w, 'val')).toEqual( + newBorder?.getAttributeNS(NamespaceUri.w, 'val') + ); + expect(originalBorder?.getAttributeNS(NamespaceUri.w, 'sz')).toEqual( + newBorder?.getAttributeNS(NamespaceUri.w, 'sz') + ); + expect(originalBorder?.getAttributeNS(NamespaceUri.w, 'space')).toEqual( + newBorder?.getAttributeNS(NamespaceUri.w, 'space') + ); + expect(originalBorder?.getAttributeNS(NamespaceUri.w, 'color')).toEqual( + newBorder?.getAttributeNS(NamespaceUri.w, 'color') + ); + }); +}); diff --git a/lib/components/document/test/Hyperlink.test.ts b/lib/components/document/test/Hyperlink.test.ts index 754c346..45914be 100644 --- a/lib/components/document/test/Hyperlink.test.ts +++ b/lib/components/document/test/Hyperlink.test.ts @@ -19,28 +19,28 @@ const emptyContext: ComponentContext = { describe('Hyperlink', () => { const hyperlink = Hyperlink.fromNode( create(` - - - Link - - - - This is a new paragraph - - - - - This is removed paragraph - - - - `), + + + Link + + + + This is a new paragraph + + + + + This is removed paragraph + + + `), emptyContext ); it('parses props correctly', () => { expect(hyperlink.props.anchor).toBe('chapter1'); expect(hyperlink.props.tooltip).toBe('link'); + expect(hyperlink.props.relationshipId).toBe('rId1'); }); it('parses children correctly', () => {