From 0ec3b64ad7db0c1ca7bd3f9303df6c9e8f944905 Mon Sep 17 00:00:00 2001 From: Dolan Date: Sun, 7 Mar 2021 21:45:59 +0000 Subject: [PATCH] Add tests --- .../table-properties/table-style.spec.ts | 22 +++++++++++++++++++ .../table/table-properties/table-style.ts | 4 +--- 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 src/file/table/table-properties/table-style.spec.ts diff --git a/src/file/table/table-properties/table-style.spec.ts b/src/file/table/table-properties/table-style.spec.ts new file mode 100644 index 0000000000..1b9b0e9748 --- /dev/null +++ b/src/file/table/table-properties/table-style.spec.ts @@ -0,0 +1,22 @@ +import { expect } from "chai"; + +import { Formatter } from "export/formatter"; + +import { TableStyle } from "./table-style"; + +describe("TableStyle", () => { + describe("#constructor", () => { + it("should create", () => { + const tableStyle = new TableStyle("test-id"); + const tree = new Formatter().format(tableStyle); + + expect(tree).to.deep.equal({ + "w:tblStyle": { + _attr: { + "w:val": "test-id", + }, + }, + }); + }); + }); +}); diff --git a/src/file/table/table-properties/table-style.ts b/src/file/table/table-properties/table-style.ts index b46f853802..22b4dc5e89 100644 --- a/src/file/table/table-properties/table-style.ts +++ b/src/file/table/table-properties/table-style.ts @@ -1,11 +1,9 @@ import { Attributes, XmlComponent } from "file/xml-components"; export class TableStyle extends XmlComponent { - public readonly styleId: string; - constructor(styleId: string) { super("w:tblStyle"); - this.styleId = styleId; + this.root.push( new Attributes({ val: styleId,