2021-12-18 15:42:35 +00:00
|
|
|
import { expect } from "chai";
|
|
|
|
|
2022-09-15 13:08:49 +01:00
|
|
|
import { Formatter } from "@export/formatter";
|
2021-12-18 15:42:35 +00:00
|
|
|
|
2022-08-31 08:59:27 +01:00
|
|
|
import { Level, LevelFormat, LevelSuffix } from "./level";
|
2021-12-18 15:42:35 +00:00
|
|
|
import { AlignmentType } from "..";
|
|
|
|
|
|
|
|
describe("Level", () => {
|
|
|
|
describe("#constructor", () => {
|
|
|
|
it("should throw an error if level exceeds 9", () => {
|
|
|
|
expect(
|
|
|
|
() =>
|
|
|
|
new Level({
|
|
|
|
level: 10,
|
|
|
|
format: LevelFormat.BULLET,
|
|
|
|
text: "test",
|
|
|
|
alignment: AlignmentType.BOTH,
|
|
|
|
start: 3,
|
|
|
|
style: { run: {}, paragraph: {} },
|
|
|
|
suffix: LevelSuffix.SPACE,
|
|
|
|
}),
|
|
|
|
).to.throw();
|
|
|
|
});
|
|
|
|
});
|
2022-09-15 13:08:49 +01:00
|
|
|
|
|
|
|
describe("isLegalNumberingStyle", () => {
|
|
|
|
it("should work", () => {
|
|
|
|
const concreteNumbering = new Level({
|
|
|
|
level: 9,
|
|
|
|
isLegalNumberingStyle: true,
|
|
|
|
});
|
|
|
|
const tree = new Formatter().format(concreteNumbering);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
"w:lvl": [
|
|
|
|
{
|
|
|
|
"w:start": {
|
|
|
|
_attr: {
|
|
|
|
"w:val": 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"w:isLgl": {},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"w:lvlJc": {
|
|
|
|
_attr: {
|
|
|
|
"w:val": "start",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
_attr: {
|
|
|
|
"w15:tentative": 1,
|
|
|
|
"w:ilvl": 9,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2021-12-18 15:42:35 +00:00
|
|
|
});
|