Simplify multiple addXXX methods into a single add method

This commit is contained in:
Dolan
2019-06-25 01:52:02 +01:00
parent c97d15cb9f
commit 384d144a85
6 changed files with 36 additions and 52 deletions

View File

@ -7,21 +7,19 @@ import { Paragraph } from "./paragraph";
import { Table } from "./table";
describe("HeaderWrapper", () => {
describe("#addParagraph", () => {
it("should call the underlying header's addParagraph", () => {
describe("#add", () => {
it("should call the underlying header's addChildElement for Paragraph", () => {
const wrapper = new HeaderWrapper(new Media(), 1);
const spy = sinon.spy(wrapper.Header, "addParagraph");
wrapper.addParagraph(new Paragraph({}));
const spy = sinon.spy(wrapper.Header, "addChildElement");
wrapper.add(new Paragraph({}));
expect(spy.called).to.equal(true);
});
});
describe("#addTable", () => {
it("should call the underlying header's addTable", () => {
it("should call the underlying header's addChildElement for Table", () => {
const wrapper = new HeaderWrapper(new Media(), 1);
const spy = sinon.spy(wrapper.Header, "addTable");
wrapper.addTable(
const spy = sinon.spy(wrapper.Header, "addChildElement");
wrapper.add(
new Table({
rows: 1,
columns: 1,
@ -35,7 +33,7 @@ describe("HeaderWrapper", () => {
describe("#addImage", () => {
it("should call the underlying header's addImage", () => {
const file = new HeaderWrapper(new Media(), 1);
const spy = sinon.spy(file.Header, "addParagraph");
const spy = sinon.spy(file.Header, "add");
// tslint:disable-next-line:no-any
file.addImage({} as any);