Files
docx-js/src/file/paragraph/run/text-run.spec.ts

42 lines
1.3 KiB
TypeScript
Raw Normal View History

import { expect } from "chai";
2018-10-26 01:04:07 +01:00
import { Formatter } from "export/formatter";
2019-11-21 01:02:46 +00:00
import { FootnoteReferenceRun } from "file/footnotes/footnote/run/reference-run";
2018-10-26 01:04:07 +01:00
import { TextRun } from "./text-run";
2016-07-12 08:46:26 +01:00
describe("TextRun", () => {
let run: TextRun;
describe("#constructor()", () => {
it("should add text into run", () => {
run = new TextRun("test");
const f = new Formatter().format(run);
2018-01-23 01:33:12 +00:00
expect(f).to.deep.equal({
"w:r": [{ "w:t": [{ _attr: { "xml:space": "preserve" } }, "test"] }],
2018-01-23 01:33:12 +00:00
});
2016-07-12 08:46:26 +01:00
});
});
2019-10-18 14:09:33 +02:00
describe("#referenceFootnote()", () => {
it("should add a valid footnote reference", () => {
2019-11-21 01:02:46 +00:00
run = new TextRun({
children: ["test", new FootnoteReferenceRun(1)],
});
2019-10-18 14:09:33 +02:00
const tree = new Formatter().format(run);
2019-11-21 01:02:46 +00:00
2019-10-18 14:09:33 +02:00
expect(tree).to.deep.equal({
"w:r": [
{ "w:t": [{ _attr: { "xml:space": "preserve" } }, "test"] },
{
"w:r": [
{ "w:rPr": [{ "w:rStyle": { _attr: { "w:val": "FootnoteReference" } } }] },
{ "w:footnoteReference": { _attr: { "w:id": 1 } } },
],
},
],
});
});
});
2017-03-09 22:56:08 +00:00
});