2018-11-01 02:22:32 +00:00
|
|
|
import { expect } from "chai";
|
|
|
|
import * as sinon from "sinon";
|
|
|
|
|
|
|
|
import { HeaderWrapper } from "./header-wrapper";
|
|
|
|
import { Media } from "./media";
|
|
|
|
import { Paragraph } from "./paragraph";
|
|
|
|
import { Table } from "./table";
|
|
|
|
|
|
|
|
describe("HeaderWrapper", () => {
|
2019-06-25 01:52:02 +01:00
|
|
|
describe("#add", () => {
|
|
|
|
it("should call the underlying header's addChildElement for Paragraph", () => {
|
2018-12-16 01:56:42 +00:00
|
|
|
const wrapper = new HeaderWrapper(new Media(), 1);
|
2019-06-25 01:52:02 +01:00
|
|
|
const spy = sinon.spy(wrapper.Header, "addChildElement");
|
|
|
|
wrapper.add(new Paragraph({}));
|
2018-11-01 02:22:32 +00:00
|
|
|
|
|
|
|
expect(spy.called).to.equal(true);
|
|
|
|
});
|
|
|
|
|
2019-06-25 01:52:02 +01:00
|
|
|
it("should call the underlying header's addChildElement for Table", () => {
|
2018-12-16 01:56:42 +00:00
|
|
|
const wrapper = new HeaderWrapper(new Media(), 1);
|
2019-06-25 01:52:02 +01:00
|
|
|
const spy = sinon.spy(wrapper.Header, "addChildElement");
|
|
|
|
wrapper.add(
|
2019-03-13 02:29:11 +00:00
|
|
|
new Table({
|
|
|
|
rows: 1,
|
|
|
|
columns: 1,
|
|
|
|
}),
|
|
|
|
);
|
2018-11-01 02:22:32 +00:00
|
|
|
|
|
|
|
expect(spy.called).to.equal(true);
|
|
|
|
});
|
|
|
|
});
|
2019-01-03 02:36:56 +00:00
|
|
|
|
|
|
|
describe("#addImage", () => {
|
|
|
|
it("should call the underlying header's addImage", () => {
|
|
|
|
const file = new HeaderWrapper(new Media(), 1);
|
2019-06-25 01:52:02 +01:00
|
|
|
const spy = sinon.spy(file.Header, "add");
|
2019-01-03 02:36:56 +00:00
|
|
|
// tslint:disable-next-line:no-any
|
|
|
|
file.addImage({} as any);
|
|
|
|
|
|
|
|
expect(spy.called).to.equal(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("#createImage", () => {
|
|
|
|
it("should call the underlying header's createImage", () => {
|
|
|
|
const file = new HeaderWrapper(new Media(), 1);
|
2019-06-25 01:21:28 +01:00
|
|
|
const spy = sinon.spy(Media, "addImage");
|
2019-01-03 02:36:56 +00:00
|
|
|
file.createImage("");
|
|
|
|
|
|
|
|
expect(spy.called).to.equal(true);
|
2019-06-25 01:21:28 +01:00
|
|
|
spy.restore();
|
2019-01-03 02:36:56 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("#addChildElement", () => {
|
|
|
|
it("should call the underlying header's addChildElement", () => {
|
|
|
|
const file = new HeaderWrapper(new Media(), 1);
|
|
|
|
const spy = sinon.spy(file.Header, "addChildElement");
|
|
|
|
// tslint:disable-next-line:no-any
|
|
|
|
file.addChildElement({} as any);
|
|
|
|
|
|
|
|
expect(spy.called).to.equal(true);
|
|
|
|
});
|
|
|
|
});
|
2018-11-01 02:22:32 +00:00
|
|
|
});
|