diff --git a/docs/usage/table-of-contents.md b/docs/usage/table-of-contents.md new file mode 100644 index 0000000000..c39c88a790 --- /dev/null +++ b/docs/usage/table-of-contents.md @@ -0,0 +1 @@ +# Table of Contents \ No newline at end of file diff --git a/src/file/table-of-contents/table-of-contents.spec.ts b/src/file/table-of-contents/table-of-contents.spec.ts index d576fa0706..9e22af0ca9 100644 --- a/src/file/table-of-contents/table-of-contents.spec.ts +++ b/src/file/table-of-contents/table-of-contents.spec.ts @@ -1,7 +1,26 @@ import { expect } from "chai"; +import { Formatter } from "../../export/formatter"; +import { TableOfContents } from "./"; + +const DEFAULT_TOC = { + "w:std": { + "w:sdtPr": {}, + "w:sdtEndPr": {}, + "w:sdtContent": { + "w:p": { + "w:pPr": {}, + }, + }, + }, +}; + describe("Table of Contents", () => { - it("should be true", () => { - expect(1).to.be.equal(1); + describe("#constructor", () => { + it("should construct a TOC with default options", () => { + const toc = new TableOfContents(); + const tree = new Formatter().format(toc); + expect(tree).to.be.deep.equal(DEFAULT_TOC); + }); }); }); diff --git a/src/file/table-of-contents/table-of-contents.ts b/src/file/table-of-contents/table-of-contents.ts index a4da01dd85..a04c94042a 100644 --- a/src/file/table-of-contents/table-of-contents.ts +++ b/src/file/table-of-contents/table-of-contents.ts @@ -1,3 +1,12 @@ import { XmlComponent } from "file/xml-components"; -export class TableOfContents extends XmlComponent {} +import { TableOfContentsProperties } from "./properties"; + +export class TableOfContents extends XmlComponent { + private readonly properties: TableOfContentsProperties; + + constructor(properties?: TableOfContentsProperties) { + super("w:std"); + this.properties = properties || new TableOfContentsProperties(); + } +}