2017-03-09 12:12:33 +01:00
|
|
|
import { expect } from "chai";
|
2017-09-17 00:00:41 +01:00
|
|
|
|
2018-10-26 01:04:07 +01:00
|
|
|
import { Formatter } from "export/formatter";
|
|
|
|
|
2018-11-01 02:22:32 +00:00
|
|
|
import { ContextualSpacing, Spacing } from "./spacing";
|
2017-03-09 12:12:33 +01:00
|
|
|
|
|
|
|
describe("Spacing", () => {
|
|
|
|
describe("#constructor", () => {
|
|
|
|
it("should set the properties given", () => {
|
2018-01-23 01:33:12 +00:00
|
|
|
const spacing = new Spacing({ before: 100, after: 120, line: 150 });
|
2017-03-09 12:12:33 +01:00
|
|
|
const tree = new Formatter().format(spacing);
|
|
|
|
expect(tree).to.deep.equal({
|
2018-01-23 01:33:12 +00:00
|
|
|
"w:spacing": [{ _attr: { "w:after": 120, "w:before": 100, "w:line": 150 } }],
|
2017-03-09 12:12:33 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should only set the given properties", () => {
|
2018-01-23 01:33:12 +00:00
|
|
|
const spacing = new Spacing({ before: 100 });
|
2017-03-09 12:12:33 +01:00
|
|
|
const tree = new Formatter().format(spacing);
|
|
|
|
expect(tree).to.deep.equal({
|
2018-01-23 01:33:12 +00:00
|
|
|
"w:spacing": [{ _attr: { "w:before": 100 } }],
|
2017-03-09 12:12:33 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2018-11-01 02:22:32 +00:00
|
|
|
|
|
|
|
describe("ContextualSpacing", () => {
|
|
|
|
describe("#constructor", () => {
|
|
|
|
it("should create", () => {
|
|
|
|
const spacing = new ContextualSpacing(true);
|
|
|
|
const tree = new Formatter().format(spacing);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:contextualSpacing": [{ _attr: { "w:val": 1 } }],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should create with value of 0 if param is false", () => {
|
|
|
|
const spacing = new ContextualSpacing(false);
|
|
|
|
const tree = new Formatter().format(spacing);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:contextualSpacing": [{ _attr: { "w:val": 0 } }],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|