Files
docx-js/src/file/numbering/abstract-numbering.spec.ts

2693 lines
110 KiB
TypeScript
Raw Normal View History

2019-11-01 01:57:01 +00:00
import { expect } from "chai";
import { Formatter } from "@export/formatter";
2019-11-01 01:57:01 +00:00
2020-05-22 12:22:45 +08:00
import { AlignmentType, EmphasisMarkType, TabStopPosition } from "../paragraph";
2019-11-01 01:57:01 +00:00
import { UnderlineType } from "../paragraph/run/underline";
import { ShadingType } from "../shading";
2019-11-01 01:57:01 +00:00
import { AbstractNumbering } from "./abstract-numbering";
import { LevelFormat, LevelSuffix } from "./level";
2019-11-01 01:57:01 +00:00
2019-11-06 20:54:39 +00:00
describe("AbstractNumbering", () => {
2019-11-01 01:57:01 +00:00
it("stores its ID at its .id property", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(5, []);
2019-11-01 01:57:01 +00:00
expect(abstractNumbering.id).to.equal(5);
});
describe("#createLevel", () => {
it("creates a level with the given characteristics", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 3,
format: LevelFormat.LOWER_LETTER,
2019-11-08 03:11:19 +00:00
text: "%1)",
alignment: AlignmentType.END,
},
]);
2019-11-01 01:57:01 +00:00
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": LevelFormat.LOWER_LETTER,
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%1)",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "end",
},
},
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 3,
},
},
],
},
],
});
2019-11-01 01:57:01 +00:00
});
it("uses 'start' as the default alignment", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 3,
format: LevelFormat.LOWER_LETTER,
2019-11-08 03:11:19 +00:00
text: "%1)",
},
]);
2019-11-01 01:57:01 +00:00
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": LevelFormat.LOWER_LETTER,
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%1)",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 3,
},
},
],
},
],
});
2019-11-01 01:57:01 +00:00
});
it("has suffix", () => {
const abstractNumbering = new AbstractNumbering(1, [
{
level: 3,
format: LevelFormat.LOWER_LETTER,
text: "%1)",
alignment: AlignmentType.END,
suffix: LevelSuffix.SPACE,
},
]);
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerLetter",
},
},
},
{
"w:suff": {
_attr: {
"w:val": "space",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%1)",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "end",
},
},
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 3,
},
},
],
},
],
});
// expect(tree["w:abstractNum"][2]["w:lvl"]).to.include({ "w:suff": { _attr: { "w:val": "space" } } });
});
2019-11-01 01:57:01 +00:00
describe("formatting methods: paragraph properties", () => {
it("#indent", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2019-11-08 03:11:19 +00:00
text: "%0.",
style: {
paragraph: {
indent: { left: 720 },
2019-11-01 01:57:01 +00:00
},
},
2019-11-08 03:11:19 +00:00
},
]);
2019-11-01 01:57:01 +00:00
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:pPr": [
{
"w:ind": {
_attr: {
"w:left": 720,
},
},
},
],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
2019-11-01 01:57:01 +00:00
});
});
it("#spacing", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2019-11-08 03:11:19 +00:00
text: "%0.",
style: {
paragraph: {
spacing: { before: 50, after: 150 },
2019-11-01 01:57:01 +00:00
},
},
2019-11-08 03:11:19 +00:00
},
]);
2019-11-01 01:57:01 +00:00
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:pPr": [
{
"w:spacing": {
_attr: {
"w:after": 150,
"w:before": 50,
},
},
},
],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
2019-11-01 01:57:01 +00:00
});
});
it("#center", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2019-11-08 03:11:19 +00:00
text: "%0.",
style: {
paragraph: {
alignment: AlignmentType.CENTER,
2019-11-01 01:57:01 +00:00
},
},
2019-11-08 03:11:19 +00:00
},
]);
2019-11-01 01:57:01 +00:00
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:pPr": [
{
"w:jc": {
_attr: {
"w:val": "center",
},
},
},
],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
2019-11-01 01:57:01 +00:00
});
});
it("#left", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2019-11-08 03:11:19 +00:00
text: "%0.",
style: {
paragraph: {
alignment: AlignmentType.LEFT,
2019-11-01 01:57:01 +00:00
},
},
2019-11-08 03:11:19 +00:00
},
]);
2019-11-01 01:57:01 +00:00
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:pPr": [
{
"w:jc": {
_attr: {
"w:val": "left",
},
},
},
],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
2019-11-01 01:57:01 +00:00
});
});
it("#right", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2019-11-08 03:11:19 +00:00
text: "%0.",
style: {
paragraph: {
alignment: AlignmentType.RIGHT,
2019-11-01 01:57:01 +00:00
},
},
2019-11-08 03:11:19 +00:00
},
]);
2019-11-01 01:57:01 +00:00
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:pPr": [
{
"w:jc": {
_attr: {
"w:val": "right",
},
},
},
],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
2019-11-01 01:57:01 +00:00
});
});
it("#justified", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2019-11-08 03:11:19 +00:00
text: "%0.",
style: {
paragraph: {
alignment: AlignmentType.JUSTIFIED,
2019-11-01 01:57:01 +00:00
},
},
2019-11-08 03:11:19 +00:00
},
]);
2019-11-01 01:57:01 +00:00
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:pPr": [
{
"w:jc": {
_attr: {
"w:val": "both",
},
},
},
],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
2019-11-01 01:57:01 +00:00
});
});
it("#thematicBreak", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2019-11-08 03:11:19 +00:00
text: "%0.",
style: {
paragraph: {
thematicBreak: true,
2019-11-01 01:57:01 +00:00
},
},
2019-11-08 03:11:19 +00:00
},
]);
2019-11-01 01:57:01 +00:00
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
2019-11-01 01:57:01 +00:00
{
2022-10-25 01:08:54 +01:00
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
2019-11-01 01:57:01 +00:00
{
2022-10-25 01:08:54 +01:00
"w:lvlJc": {
2019-11-01 01:57:01 +00:00
_attr: {
2022-10-25 01:08:54 +01:00
"w:val": "start",
2019-11-01 01:57:01 +00:00
},
},
},
2022-10-25 01:08:54 +01:00
{
"w:pPr": [
{
"w:pBdr": [
{
"w:bottom": {
_attr: {
"w:color": "auto",
"w:space": 1,
"w:sz": 6,
"w:val": "single",
},
},
},
],
},
],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
2019-11-01 01:57:01 +00:00
],
},
],
});
});
it("#leftTabStop", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2019-11-08 03:11:19 +00:00
text: "%0.",
style: {
paragraph: {
leftTabStop: 1200,
2019-11-01 01:57:01 +00:00
},
},
2019-11-08 03:11:19 +00:00
},
]);
2019-11-01 01:57:01 +00:00
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
2019-11-01 01:57:01 +00:00
{
2022-10-25 01:08:54 +01:00
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:pPr": [
{
"w:tabs": [
{
"w:tab": {
_attr: {
"w:pos": 1200,
"w:val": "left",
},
},
},
],
},
],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
2019-11-01 01:57:01 +00:00
},
],
});
});
it("#maxRightTabStop", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2019-11-08 03:11:19 +00:00
text: "%0.",
style: {
paragraph: {
rightTabStop: TabStopPosition.MAX,
2019-11-01 01:57:01 +00:00
},
},
2019-11-08 03:11:19 +00:00
},
]);
2019-11-01 01:57:01 +00:00
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
2019-11-01 01:57:01 +00:00
{
2022-10-25 01:08:54 +01:00
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:pPr": [
{
"w:tabs": [
{
"w:tab": {
_attr: {
"w:pos": 9026,
"w:val": "right",
},
},
},
],
},
],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
2019-11-01 01:57:01 +00:00
},
],
});
});
it("#keepLines", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2019-11-08 03:11:19 +00:00
text: "%0.",
style: {
paragraph: {
keepLines: true,
2019-11-01 01:57:01 +00:00
},
},
2019-11-08 03:11:19 +00:00
},
]);
2019-11-01 01:57:01 +00:00
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:pPr": [
{
"w:keepLines": {},
},
],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
2019-11-01 01:57:01 +00:00
});
});
it("#keepNext", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2019-11-08 03:11:19 +00:00
text: "%0.",
style: {
paragraph: {
keepNext: true,
2019-11-01 01:57:01 +00:00
},
},
2019-11-08 03:11:19 +00:00
},
]);
2019-11-01 01:57:01 +00:00
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:pPr": [
{
"w:keepNext": {},
},
],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
2019-11-01 01:57:01 +00:00
});
});
});
describe("formatting methods: run properties", () => {
2020-07-15 12:46:46 +08:00
const sizeTests = [
{
size: 24,
expected: [{ "w:sz": { _attr: { "w:val": 24 } } }, { "w:szCs": { _attr: { "w:val": 24 } } }],
},
{
size: 24,
sizeComplexScript: true,
expected: [{ "w:sz": { _attr: { "w:val": 24 } } }, { "w:szCs": { _attr: { "w:val": 24 } } }],
},
{
size: 24,
sizeComplexScript: false,
expected: [{ "w:sz": { _attr: { "w:val": 24 } } }],
},
{
size: 24,
sizeComplexScript: 26,
expected: [{ "w:sz": { _attr: { "w:val": 24 } } }, { "w:szCs": { _attr: { "w:val": 26 } } }],
},
];
sizeTests.forEach(({ size, sizeComplexScript, expected }) => {
it(`#size ${size} cs ${sizeComplexScript}`, () => {
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2020-07-15 12:46:46 +08:00
text: "%0.",
style: {
run: { size, sizeComplexScript },
2019-11-01 01:57:01 +00:00
},
2022-10-25 01:08:54 +01:00
},
]);
const tree = new Formatter().format(abstractNumbering);
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:rPr": expected,
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
});
2019-11-01 01:57:01 +00:00
});
});
it("#smallCaps", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2019-11-08 03:11:19 +00:00
text: "%0.",
style: {
run: {
smallCaps: true,
2019-11-01 01:57:01 +00:00
},
},
2019-11-08 03:11:19 +00:00
},
]);
2019-11-01 01:57:01 +00:00
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:rPr": [
{
"w:smallCaps": {},
},
],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
2019-11-01 01:57:01 +00:00
});
});
it("#allCaps", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2019-11-08 03:11:19 +00:00
text: "%0.",
style: {
run: {
allCaps: true,
2019-11-01 01:57:01 +00:00
},
},
2019-11-08 03:11:19 +00:00
},
]);
2019-11-01 01:57:01 +00:00
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:rPr": [
{
"w:caps": {},
},
],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
2019-11-01 01:57:01 +00:00
});
});
it("#strike", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2019-11-08 03:11:19 +00:00
text: "%0.",
style: {
run: {
strike: true,
2019-11-01 01:57:01 +00:00
},
},
2019-11-08 03:11:19 +00:00
},
]);
2019-11-01 01:57:01 +00:00
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:rPr": [
{
"w:strike": {},
},
],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
2019-11-01 01:57:01 +00:00
});
});
it("#doubleStrike", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2019-11-08 03:11:19 +00:00
text: "%0.",
style: {
run: {
doubleStrike: true,
2019-11-01 01:57:01 +00:00
},
},
2019-11-08 03:11:19 +00:00
},
]);
2019-11-01 01:57:01 +00:00
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:rPr": [
{
"w:dstrike": {},
},
],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
2019-11-01 01:57:01 +00:00
});
});
it("#subScript", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2019-11-08 03:11:19 +00:00
text: "%0.",
style: {
run: {
subScript: true,
2019-11-01 01:57:01 +00:00
},
},
2019-11-08 03:11:19 +00:00
},
]);
2019-11-01 01:57:01 +00:00
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:rPr": [{ "w:vertAlign": { _attr: { "w:val": "subscript" } } }],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
2019-11-01 01:57:01 +00:00
});
});
it("#superScript", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2019-11-08 03:11:19 +00:00
text: "%0.",
style: {
run: {
superScript: true,
2019-11-01 01:57:01 +00:00
},
},
2019-11-08 03:11:19 +00:00
},
]);
2019-11-01 01:57:01 +00:00
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:rPr": [{ "w:vertAlign": { _attr: { "w:val": "superscript" } } }],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
2019-11-01 01:57:01 +00:00
});
});
2020-06-07 12:38:31 +08:00
it("#font by name", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2019-11-08 03:11:19 +00:00
text: "%0.",
style: {
run: {
font: "Times",
2019-11-01 01:57:01 +00:00
},
},
2019-11-08 03:11:19 +00:00
},
]);
2019-11-01 01:57:01 +00:00
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
2020-05-22 12:22:45 +08:00
{
2022-10-25 01:08:54 +01:00
"w:multiLevelType": {
2020-05-22 12:22:45 +08:00
_attr: {
2022-10-25 01:08:54 +01:00
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
2020-05-22 12:22:45 +08:00
},
2022-10-25 01:08:54 +01:00
{
"w:rPr": [
{
"w:rFonts": {
_attr: {
"w:ascii": "Times",
"w:cs": "Times",
"w:eastAsia": "Times",
"w:hAnsi": "Times",
},
},
},
],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
2020-05-22 12:22:45 +08:00
},
2019-11-01 01:57:01 +00:00
],
});
});
2020-06-07 12:38:31 +08:00
it("#font for ascii and eastAsia", () => {
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2020-06-07 12:38:31 +08:00
text: "%0.",
style: {
run: {
font: {
ascii: "Times",
eastAsia: "KaiTi",
},
},
},
},
]);
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
2020-06-07 12:38:31 +08:00
{
2022-10-25 01:08:54 +01:00
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
2020-06-07 12:38:31 +08:00
_attr: {
2022-10-25 01:08:54 +01:00
"w:val": "hybridMultilevel",
2020-06-07 12:38:31 +08:00
},
},
},
2022-10-25 01:08:54 +01:00
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:rPr": [
{
"w:rFonts": {
_attr: {
"w:ascii": "Times",
"w:eastAsia": "KaiTi",
},
},
},
],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
2020-06-07 12:38:31 +08:00
],
});
});
2020-07-15 12:46:46 +08:00
const boldTests = [
{
bold: true,
expected: [{ "w:b": {} }, { "w:bCs": {} }],
2020-07-15 12:46:46 +08:00
},
{
bold: true,
boldComplexScript: true,
expected: [{ "w:b": {} }, { "w:bCs": {} }],
2020-07-15 12:46:46 +08:00
},
{
bold: true,
boldComplexScript: false,
expected: [{ "w:b": {} }],
2020-07-15 12:46:46 +08:00
},
];
boldTests.forEach(({ bold, boldComplexScript, expected }) => {
it(`#bold ${bold} cs ${boldComplexScript}`, () => {
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2020-07-15 12:46:46 +08:00
text: "%0.",
style: {
run: { bold, boldComplexScript },
2019-11-01 01:57:01 +00:00
},
},
2020-07-15 12:46:46 +08:00
]);
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:rPr": expected,
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
});
2019-11-01 01:57:01 +00:00
});
});
2020-07-15 12:46:46 +08:00
const italicsTests = [
{
italics: true,
expected: [{ "w:i": {} }, { "w:iCs": {} }],
2020-07-15 12:46:46 +08:00
},
{
italics: true,
italicsComplexScript: true,
expected: [{ "w:i": {} }, { "w:iCs": {} }],
2020-07-15 12:46:46 +08:00
},
{
italics: true,
italicsComplexScript: false,
expected: [{ "w:i": {} }],
2020-07-15 12:46:46 +08:00
},
];
italicsTests.forEach(({ italics, italicsComplexScript, expected }) => {
it(`#italics ${italics} cs ${italicsComplexScript}`, () => {
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2020-07-15 12:46:46 +08:00
text: "%0.",
style: {
run: { italics, italicsComplexScript },
2019-11-01 01:57:01 +00:00
},
},
2020-07-15 12:46:46 +08:00
]);
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:rPr": expected,
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
});
2019-11-01 01:57:01 +00:00
});
});
2020-07-15 12:46:46 +08:00
const highlightTests = [
{
highlight: "005599",
expected: [{ "w:highlight": { _attr: { "w:val": "005599" } } }, { "w:highlightCs": { _attr: { "w:val": "005599" } } }],
},
{
highlight: "005599",
highlightComplexScript: true,
expected: [{ "w:highlight": { _attr: { "w:val": "005599" } } }, { "w:highlightCs": { _attr: { "w:val": "005599" } } }],
},
{
highlight: "005599",
highlightComplexScript: false,
expected: [{ "w:highlight": { _attr: { "w:val": "005599" } } }],
},
{
highlight: "005599",
highlightComplexScript: "550099",
expected: [{ "w:highlight": { _attr: { "w:val": "005599" } } }, { "w:highlightCs": { _attr: { "w:val": "550099" } } }],
},
];
highlightTests.forEach(({ highlight, highlightComplexScript, expected }) => {
it(`#highlight ${highlight} cs ${highlightComplexScript}`, () => {
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2020-07-15 12:46:46 +08:00
text: "%0.",
style: {
run: { highlight, highlightComplexScript },
2019-11-01 01:57:01 +00:00
},
},
2020-07-15 12:46:46 +08:00
]);
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:rPr": expected,
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
});
2019-11-01 01:57:01 +00:00
});
});
2020-07-15 12:46:46 +08:00
const shadingTests = [
{
shading: {
2021-05-29 05:51:06 +03:00
type: ShadingType.DIAGONAL_STRIPE,
fill: "006622",
color: "0000FF",
2020-07-15 12:46:46 +08:00
},
expected: [{ "w:shd": { _attr: { "w:val": "diagStripe", "w:fill": "006622", "w:color": "0000FF" } } }],
2020-07-15 12:46:46 +08:00
},
{
shading: {
2021-05-29 05:51:06 +03:00
type: ShadingType.PERCENT_10,
2020-07-15 12:46:46 +08:00
fill: "00FFFF",
color: "FF0000",
},
2021-05-20 04:08:00 +03:00
expected: [{ "w:shd": { _attr: { "w:val": "pct10", "w:fill": "00FFFF", "w:color": "FF0000" } } }],
2020-07-15 12:46:46 +08:00
},
];
shadingTests.forEach(({ shading, expected }) => {
it("#shade correctly", () => {
2020-07-15 12:46:46 +08:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2020-07-15 12:46:46 +08:00
text: "%0.",
style: {
run: { shading },
2019-11-01 01:57:01 +00:00
},
},
2020-07-15 12:46:46 +08:00
]);
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:rPr": expected,
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
});
2019-11-01 01:57:01 +00:00
});
});
describe("#underline", () => {
it("should set underline to 'single' if no arguments are given", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2019-11-08 03:11:19 +00:00
text: "%0.",
style: {
run: {
underline: {},
2019-11-01 01:57:01 +00:00
},
},
2019-11-08 03:11:19 +00:00
},
]);
2019-11-01 01:57:01 +00:00
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:rPr": [{ "w:u": { _attr: { "w:val": "single" } } }],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
2019-11-01 01:57:01 +00:00
});
});
it("should set the style if given", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2019-11-08 03:11:19 +00:00
text: "%0.",
style: {
run: {
underline: {
type: UnderlineType.DOUBLE,
2019-11-01 01:57:01 +00:00
},
},
},
2019-11-08 03:11:19 +00:00
},
]);
2019-11-01 01:57:01 +00:00
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:rPr": [{ "w:u": { _attr: { "w:val": "double" } } }],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
2019-11-01 01:57:01 +00:00
});
});
it("should set the style and color if given", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2019-11-08 03:11:19 +00:00
text: "%0.",
style: {
run: {
underline: {
type: UnderlineType.DOUBLE,
color: "005599",
2019-11-01 01:57:01 +00:00
},
},
},
2019-11-08 03:11:19 +00:00
},
]);
2019-11-01 01:57:01 +00:00
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:rPr": [{ "w:u": { _attr: { "w:val": "double", "w:color": "005599" } } }],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
2019-11-01 01:57:01 +00:00
});
});
});
2020-05-22 12:22:45 +08:00
describe("#emphasisMark", () => {
it("should set emphasisMark to 'dot' if no arguments are given", () => {
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2020-05-22 12:22:45 +08:00
text: "%0.",
style: {
run: {
emphasisMark: {},
},
},
},
]);
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:rPr": [{ "w:em": { _attr: { "w:val": "dot" } } }],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
2020-05-22 12:22:45 +08:00
});
});
it("should set the style if given", () => {
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2020-05-22 12:22:45 +08:00
text: "%0.",
style: {
run: {
emphasisMark: {
type: EmphasisMarkType.DOT,
},
},
},
},
]);
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:rPr": [{ "w:em": { _attr: { "w:val": "dot" } } }],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
2020-05-22 12:22:45 +08:00
});
});
});
2019-11-01 01:57:01 +00:00
it("#color", () => {
2019-11-08 03:11:19 +00:00
const abstractNumbering = new AbstractNumbering(1, [
{
level: 0,
format: LevelFormat.LOWER_ROMAN,
2019-11-08 03:11:19 +00:00
text: "%0.",
style: {
run: {
color: "123456",
2019-11-01 01:57:01 +00:00
},
},
2019-11-08 03:11:19 +00:00
},
]);
2019-11-01 01:57:01 +00:00
const tree = new Formatter().format(abstractNumbering);
2022-10-25 01:08:54 +01:00
expect(tree).to.deep.equal({
"w:abstractNum": [
{
_attr: {
"w15:restartNumberingAfterBreak": 0,
"w:abstractNumId": 1,
},
},
{
"w:multiLevelType": {
_attr: {
"w:val": "hybridMultilevel",
},
},
},
{
"w:lvl": [
{
"w:start": {
_attr: {
"w:val": 1,
},
},
},
{
"w:numFmt": {
_attr: {
"w:val": "lowerRoman",
},
},
},
{
"w:lvlText": {
_attr: {
"w:val": "%0.",
},
},
},
{
"w:lvlJc": {
_attr: {
"w:val": "start",
},
},
},
{
"w:rPr": [{ "w:color": { _attr: { "w:val": "123456" } } }],
},
{
_attr: {
"w15:tentative": 1,
"w:ilvl": 0,
},
},
],
},
],
2019-11-01 01:57:01 +00:00
});
});
});
});
});