2018-08-22 10:30:19 -03:00
|
|
|
import { expect } from "chai";
|
|
|
|
|
2018-08-29 12:06:01 -03:00
|
|
|
import { Formatter } from "../../export/formatter";
|
|
|
|
import { TableOfContents } from "./";
|
|
|
|
|
|
|
|
const DEFAULT_TOC = {
|
2018-08-31 10:22:40 -03:00
|
|
|
"w:p": [
|
|
|
|
{
|
|
|
|
"w:pPr": [],
|
2018-08-29 12:06:01 -03:00
|
|
|
},
|
2018-09-03 10:48:50 -03:00
|
|
|
{
|
2018-09-03 11:20:36 -03:00
|
|
|
"w:fldChar": [
|
2018-09-03 10:48:50 -03:00
|
|
|
{
|
2018-09-03 11:20:36 -03:00
|
|
|
_attr: {
|
|
|
|
"w:fldCharType": "begin",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"w:fldChar": [
|
|
|
|
{
|
|
|
|
_attr: {
|
|
|
|
"w:fldCharType": "separate",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"w:instrText": [
|
|
|
|
{
|
|
|
|
_attr: {
|
|
|
|
"xml:space": "preserve",
|
|
|
|
},
|
|
|
|
},
|
2018-09-04 17:29:24 -03:00
|
|
|
'TOC \\n "1-6"',
|
2018-09-03 11:20:36 -03:00
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"w:fldChar": [
|
|
|
|
{
|
|
|
|
_attr: {
|
|
|
|
"w:fldCharType": "end",
|
|
|
|
},
|
2018-09-03 10:48:50 -03:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2018-08-31 10:22:40 -03:00
|
|
|
],
|
2018-08-29 12:06:01 -03:00
|
|
|
};
|
|
|
|
|
2018-08-22 10:30:19 -03:00
|
|
|
describe("Table of Contents", () => {
|
2018-08-29 12:06:01 -03:00
|
|
|
describe("#constructor", () => {
|
|
|
|
it("should construct a TOC with default options", () => {
|
|
|
|
const toc = new TableOfContents();
|
|
|
|
const tree = new Formatter().format(toc);
|
2018-09-03 11:20:36 -03:00
|
|
|
// console.log(JSON.stringify(tree, null, 2));
|
2018-08-29 12:06:01 -03:00
|
|
|
expect(tree).to.be.deep.equal(DEFAULT_TOC);
|
|
|
|
});
|
2018-08-22 10:30:19 -03:00
|
|
|
});
|
|
|
|
});
|