2017-04-14 11:01:47 +02:00
|
|
|
import { expect } from "chai";
|
2017-09-17 00:00:41 +01:00
|
|
|
|
2022-06-26 23:26:42 +01:00
|
|
|
import { Formatter } from "@export/formatter";
|
2022-12-06 22:04:30 +00:00
|
|
|
import { SpaceType } from "@file/shared";
|
2018-10-26 01:04:07 +01:00
|
|
|
|
2017-09-17 00:00:41 +01:00
|
|
|
import { Text } from "./text";
|
2017-04-14 11:01:47 +02:00
|
|
|
|
|
|
|
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"],
|
|
|
|
});
|
2017-04-14 11:01:47 +02:00
|
|
|
});
|
2022-12-06 22:04:30 +00:00
|
|
|
|
|
|
|
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"],
|
|
|
|
});
|
|
|
|
});
|
2017-04-14 11:01:47 +02:00
|
|
|
});
|
|
|
|
});
|