Files
docx-js/src/file/settings/settings.spec.ts

66 lines
2.1 KiB
TypeScript
Raw Normal View History

2018-09-20 10:11:59 -03:00
import { expect } from "chai";
2018-10-26 01:04:07 +01:00
import { Formatter } from "export/formatter";
import { Settings } from "./settings";
2018-09-20 10:11:59 -03:00
describe("Settings", () => {
describe("#constructor", () => {
it("should create a empty Settings with correct rootKey", () => {
const settings = new Settings({});
2018-09-20 10:11:59 -03:00
const tree = new Formatter().format(settings);
expect(Object.keys(tree)).has.length(1);
expect(tree["w:settings"]).to.be.an("array");
2018-09-20 10:11:59 -03:00
});
it("should add updateFields setting", () => {
2021-03-16 00:57:27 +00:00
const settings = new Settings({
updateFields: true,
2021-03-16 00:57:27 +00:00
});
const tree = new Formatter().format(settings);
expect(Object.keys(tree)).has.length(1);
expect(tree["w:settings"]).to.be.an("array");
expect(tree["w:settings"]).to.deep.include({
"w:updateFields": {},
2021-03-16 00:57:27 +00:00
});
2018-09-20 10:11:59 -03:00
});
it("should indicate modern word compatibility by default", () => {
const settings = new Settings({});
const tree = new Formatter().format(settings);
expect(Object.keys(tree)).has.length(1);
expect(tree["w:settings"]).to.be.an("array");
const compat = tree["w:settings"][2];
expect(compat).to.be.an("object").with.keys("w:compat");
expect(compat["w:compat"]).to.deep.include({
2021-02-27 01:40:55 +00:00
"w:compatSetting": {
_attr: {
"w:val": 15,
"w:uri": "http://schemas.microsoft.com/office/word",
"w:name": "compatibilityMode",
},
},
});
});
it("should add trackRevisions setting", () => {
2021-03-16 00:57:27 +00:00
const settings = new Settings({
trackRevisions: true,
2021-03-16 00:57:27 +00:00
});
const tree = new Formatter().format(settings);
expect(Object.keys(tree)).has.length(1);
expect(tree["w:settings"]).to.be.an("array");
2021-03-16 00:57:27 +00:00
expect(tree["w:settings"]).to.deep.include({
"w:trackRevisions": {},
2021-03-16 00:57:27 +00:00
});
});
});
2018-09-20 10:11:59 -03:00
});