Write tests

This commit is contained in:
Dolan
2019-01-15 21:40:19 +00:00
committed by filippomuscolino
parent 14a1d62148
commit 4b6d3c3e3c
2 changed files with 55 additions and 0 deletions

View File

@ -0,0 +1,23 @@
import { expect } from "chai";
import { Formatter } from "export/formatter";
import { NumberOfPages, Page } from "./page-number";
describe("Page", () => {
describe("#constructor()", () => {
it("uses the font name for both ascii and hAnsi", () => {
const tree = new Formatter().format(new Page());
expect(tree).to.deep.equal({ "w:instrText": [{ _attr: { "xml:space": "preserve" } }, "PAGE"] });
});
});
});
describe("NumberOfPages", () => {
describe("#constructor()", () => {
it("uses the font name for both ascii and hAnsi", () => {
const tree = new Formatter().format(new NumberOfPages());
expect(tree).to.deep.equal({ "w:instrText": [{ _attr: { "xml:space": "preserve" } }, "NUMPAGES"] });
});
});
});

View File

@ -156,6 +156,38 @@ describe("Run", () => {
});
});
describe("#numberOfTotalPages", () => {
it("should set the run to the RTL mode", () => {
run.numberOfTotalPages();
const tree = new Formatter().format(run);
expect(tree).to.deep.equal({
"w:r": [
{ "w:rPr": [] },
{ "w:fldChar": [{ _attr: { "w:fldCharType": "begin" } }] },
{ "w:instrText": [{ _attr: { "xml:space": "preserve" } }, "NUMPAGES"] },
{ "w:fldChar": [{ _attr: { "w:fldCharType": "separate" } }] },
{ "w:fldChar": [{ _attr: { "w:fldCharType": "end" } }] },
],
});
});
});
describe("#pageNumber", () => {
it("should set the run to the RTL mode", () => {
run.pageNumber();
const tree = new Formatter().format(run);
expect(tree).to.deep.equal({
"w:r": [
{ "w:rPr": [] },
{ "w:fldChar": [{ _attr: { "w:fldCharType": "begin" } }] },
{ "w:instrText": [{ _attr: { "xml:space": "preserve" } }, "PAGE"] },
{ "w:fldChar": [{ _attr: { "w:fldCharType": "separate" } }] },
{ "w:fldChar": [{ _attr: { "w:fldCharType": "end" } }] },
],
});
});
});
describe("#style", () => {
it("should set the style to the given styleId", () => {
run.style("myRunStyle");