Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions lib/components/document/test/Cell.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,50 @@ describe('Cell - with colspan', () => {
expect(originalCellWidths).toEqual(newCellWidths);
});
});

describe('Cell - with borders', () => {
const tableNode = create(`
<w:tbl xmlns:w="${NamespaceUri.w}">
<w:tblGrid>
<w:gridCol w:w="1129"/>
</w:tblGrid>
<w:tr>
<w:tc>
<w:tcPr>
<w:tcBorders>
<w:top w:val="double" w:sz="24" w:space="0" w:color="FF0000"/>
</w:tcBorders>
</w:tcPr>
<w:p/>
</w:tc>
</w:tr>
</w:tbl>
`);

it('cell width', async () => {
const fromNode = Table.fromNode(tableNode, emptyContext);
const toNode = await fromNode.toNode([]);

const originalBorder = evaluateXPathToFirstNode<Element>(
`./descendant::Q{${NamespaceUri.w}}tcBorders`,
tableNode
);
const newBorder = evaluateXPathToFirstNode<Element>(
`./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')
);
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you use a round-robin test? See createXmlRoundRobinTest and createObjectRoundRobinTest

});
32 changes: 16 additions & 16 deletions lib/components/document/test/Hyperlink.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@ const emptyContext: ComponentContext = {
describe('Hyperlink', () => {
const hyperlink = Hyperlink.fromNode(
create(`
<w:hyperlink xmlns:w="${NamespaceUri.w}" w:anchor="chapter1" w:tooltip="link">
<w:r>
<w:t>Link</w:t>
</w:r>
<w:ins w:id="1">
<w:r>
<w:t xml:space="preserve">This is a new paragraph</w:t>
</w:r>
</w:ins>
<w:del w:id="1">
<w:r>
<w:delText xml:space="preserve">This is removed paragraph</w:delText>
</w:r>
</w:del>
</w:hyperlink>
`),
<w:hyperlink xmlns:w="${NamespaceUri.w}" xmlns:r="${NamespaceUri.r}" r:id="rId1" w:anchor="chapter1" w:tooltip="link">
<w:r>
<w:t>Link</w:t>
</w:r>
<w:ins w:id="1">
<w:r>
<w:t xml:space="preserve">This is a new paragraph</w:t>
</w:r>
</w:ins>
<w:del w:id="1">
<w:r>
<w:delText xml:space="preserve">This is removed paragraph</w:delText>
</w:r>
</w:del>
</w:hyperlink>`),
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', () => {
Expand Down
Loading