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

40 lines
1.3 KiB
TypeScript
Raw Normal View History

import { expect } from "chai";
import { Formatter } from "@export/formatter";
import { SpaceType } from "@file/shared";
2018-10-26 01:04:07 +01:00
import { Text } from "./text";
describe("Text", () => {
describe("#constructor", () => {
it("adds the passed in text to the component", () => {
const t = new Text(" this is\n text");
const f = new Formatter().format(t);
2018-01-23 01:33:12 +00:00
expect(f).to.deep.equal({
"w:t": [{ _attr: { "xml:space": "preserve" } }, " this is\n text"],
});
});
it("adds the passed in text to the component with options", () => {
const t = new Text({
text: " this is\n text",
space: SpaceType.PRESERVE,
});
const f = new Formatter().format(t);
expect(f).to.deep.equal({
"w:t": [{ _attr: { "xml:space": "preserve" } }, " this is\n text"],
});
});
it("adds the passed in text to the component with options and sets default space type", () => {
const t = new Text({
text: " this is\n text",
});
const f = new Formatter().format(t);
expect(f).to.deep.equal({
"w:t": [{ _attr: { "xml:space": "default" } }, " this is\n text"],
});
});
});
});