From 4b6d3c3e3c4bdbd5ee402da62adbfafc39eba2ee Mon Sep 17 00:00:00 2001 From: Dolan Date: Tue, 15 Jan 2019 21:40:19 +0000 Subject: [PATCH] Write tests --- src/file/paragraph/run/page-number.spec.ts | 23 ++++++++++++++++ src/file/paragraph/run/run.spec.ts | 32 ++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 src/file/paragraph/run/page-number.spec.ts diff --git a/src/file/paragraph/run/page-number.spec.ts b/src/file/paragraph/run/page-number.spec.ts new file mode 100644 index 0000000000..4a9bc39a3e --- /dev/null +++ b/src/file/paragraph/run/page-number.spec.ts @@ -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"] }); + }); + }); +}); diff --git a/src/file/paragraph/run/run.spec.ts b/src/file/paragraph/run/run.spec.ts index bd9f3bf778..b1fbc8794a 100644 --- a/src/file/paragraph/run/run.spec.ts +++ b/src/file/paragraph/run/run.spec.ts @@ -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");