:test: document defaults & numbering suffix

This commit is contained in:
wangfengming
2020-07-15 14:11:26 +08:00
parent 36e1c5fe6a
commit 3f7ca6bbff
2 changed files with 60 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import { AlignmentType, EmphasisMarkType, TabStopPosition } from "../paragraph";
import { UnderlineType } from "../paragraph/run/underline"; import { UnderlineType } from "../paragraph/run/underline";
import { ShadingType } from "../table"; import { ShadingType } from "../table";
import { AbstractNumbering } from "./abstract-numbering"; import { AbstractNumbering } from "./abstract-numbering";
import { LevelSuffix } from "./level";
describe("AbstractNumbering", () => { describe("AbstractNumbering", () => {
it("stores its ID at its .id property", () => { it("stores its ID at its .id property", () => {
@ -48,6 +49,20 @@ describe("AbstractNumbering", () => {
expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({ "w:lvlText": { _attr: { "w:val": "%1)" } } }); expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({ "w:lvlText": { _attr: { "w:val": "%1)" } } });
}); });
it("has suffix", () => {
const abstractNumbering = new AbstractNumbering(1, [
{
level: 3,
format: "lowerLetter",
text: "%1)",
alignment: AlignmentType.END,
suffix: LevelSuffix.SPACE,
},
]);
const tree = new Formatter().format(abstractNumbering);
expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({ "w:suff": { _attr: { "w:val": "space" } } });
});
describe("formatting methods: paragraph properties", () => { describe("formatting methods: paragraph properties", () => {
it("#indent", () => { it("#indent", () => {
const abstractNumbering = new AbstractNumbering(1, [ const abstractNumbering = new AbstractNumbering(1, [

View File

@ -0,0 +1,45 @@
import { expect } from "chai";
import { DocumentDefaults } from "./document-defaults";
import { Formatter } from "export/formatter";
describe("DocumentDefaults", () => {
it("#constructor", () => {
const defaults = new DocumentDefaults({
paragraph: { spacing: { line: 240 } },
run: { color: "808080" },
});
const tree = new Formatter().format(defaults);
expect(tree).to.deep.equal({
"w:docDefaults": [
{
"w:rPrDefault": [
{
"w:rPr": [
{
"w:color": { _attr: { "w:val": "808080" } },
},
],
},
],
},
{
"w:pPrDefault": [
{
"w:pPr": [
{
"w:spacing": {
_attr: {
"w:line": 240,
},
},
},
],
},
],
},
],
});
});
});