Write tests
This commit is contained in:
23
src/file/paragraph/run/page-number.spec.ts
Normal file
23
src/file/paragraph/run/page-number.spec.ts
Normal 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"] });
|
||||
});
|
||||
});
|
||||
});
|
@ -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");
|
||||
|
Reference in New Issue
Block a user