Add tests and clean up code
This commit is contained in:
@ -1,11 +1,87 @@
|
||||
import { assert, expect } from "chai";
|
||||
import { expect } from "chai";
|
||||
|
||||
import { Formatter } from "export/formatter";
|
||||
|
||||
import { ThematicBreak } from "./border";
|
||||
import { Border, ThematicBreak } from "./border";
|
||||
|
||||
describe("Border", () => {
|
||||
// TODO: Need tests here
|
||||
describe("#constructor", () => {
|
||||
it("should create", () => {
|
||||
const border = new Border({
|
||||
top: {
|
||||
color: "red",
|
||||
space: 1,
|
||||
value: "test",
|
||||
size: 2,
|
||||
},
|
||||
bottom: {
|
||||
color: "red",
|
||||
space: 3,
|
||||
value: "test",
|
||||
size: 4,
|
||||
},
|
||||
left: {
|
||||
color: "red",
|
||||
space: 5,
|
||||
value: "test",
|
||||
size: 6,
|
||||
},
|
||||
right: {
|
||||
color: "red",
|
||||
space: 7,
|
||||
value: "test",
|
||||
size: 8,
|
||||
},
|
||||
});
|
||||
|
||||
const tree = new Formatter().format(border);
|
||||
|
||||
expect(tree).to.deep.equal({
|
||||
"w:pBdr": [
|
||||
{
|
||||
"w:top": {
|
||||
_attr: {
|
||||
"w:color": "red",
|
||||
"w:space": 1,
|
||||
"w:sz": 2,
|
||||
"w:val": "test",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:bottom": {
|
||||
_attr: {
|
||||
"w:color": "red",
|
||||
"w:space": 3,
|
||||
"w:sz": 4,
|
||||
"w:val": "test",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:left": {
|
||||
_attr: {
|
||||
"w:color": "red",
|
||||
"w:space": 5,
|
||||
"w:sz": 6,
|
||||
"w:val": "test",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:right": {
|
||||
_attr: {
|
||||
"w:color": "red",
|
||||
"w:space": 7,
|
||||
"w:sz": 8,
|
||||
"w:val": "test",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("ThematicBreak", () => {
|
||||
@ -16,17 +92,6 @@ describe("ThematicBreak", () => {
|
||||
});
|
||||
|
||||
describe("#constructor()", () => {
|
||||
it("should create valid JSON", () => {
|
||||
const stringifiedJson = JSON.stringify(thematicBreak);
|
||||
|
||||
try {
|
||||
JSON.parse(stringifiedJson);
|
||||
} catch (e) {
|
||||
assert.isTrue(false);
|
||||
}
|
||||
assert.isTrue(true);
|
||||
});
|
||||
|
||||
it("should create a Thematic Break with correct border properties", () => {
|
||||
const tree = new Formatter().format(thematicBreak);
|
||||
expect(tree).to.deep.equal({
|
||||
|
Reference in New Issue
Block a user