Files
docx-js/src/file/header-wrapper.spec.ts

51 lines
1.7 KiB
TypeScript
Raw Normal View History

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";
2019-09-13 00:51:20 +01:00
import { Table, TableCell, TableRow } from "./table";
2018-11-01 02:22:32 +00:00
describe("HeaderWrapper", () => {
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);
const spy = sinon.spy(wrapper.Header, "add");
wrapper.add(new Paragraph({}));
2018-11-01 02:22:32 +00:00
expect(spy.called).to.equal(true);
});
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);
const spy = sinon.spy(wrapper.Header, "add");
wrapper.add(
2019-03-13 02:29:11 +00:00
new Table({
2019-09-13 00:51:20 +01:00
rows: [
new TableRow({
children: [
new TableCell({
children: [new Paragraph("hello")],
}),
],
}),
],
2019-03-13 02:29:11 +00:00
}),
);
2018-11-01 02:22:32 +00:00
expect(spy.called).to.equal(true);
});
});
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
});