Turn methods into "add()"

This commit is contained in:
Dolan
2019-06-25 23:17:56 +01:00
parent 3ef8f5311d
commit e2574ec23b
55 changed files with 253 additions and 262 deletions

View File

@ -80,20 +80,18 @@ describe("File", () => {
});
});
describe("#addParagraph", () => {
it("should call the underlying document's addParagraph", () => {
describe("#add", () => {
it("should call the underlying document's add a Paragraph", () => {
const file = new File();
const spy = sinon.spy(file.Document, "addParagraph");
const spy = sinon.spy(file.Document, "add");
file.add(new Paragraph({}));
expect(spy.called).to.equal(true);
});
});
describe("#add", () => {
it("should call the underlying document's addTable", () => {
it("should call the underlying document's add when adding a Table", () => {
const wrapper = new File();
const spy = sinon.spy(wrapper.Document, "addTable");
const spy = sinon.spy(wrapper.Document, "add");
wrapper.add(
new Table({
rows: 1,
@ -104,6 +102,17 @@ describe("File", () => {
expect(spy.called).to.equal(true);
});
it("should call the underlying document's add when adding an Image (paragraph)", () => {
const wrapper = new File();
const spy = sinon.spy(wrapper.Document, "add");
// tslint:disable-next-line:no-any
wrapper.add(new Paragraph(""));
expect(spy.called).to.equal(true);
});
});
describe("#add", () => {
it("should call the underlying document's addTableOfContents", () => {
const wrapper = new File();
const spy = sinon.spy(wrapper.Document, "addTableOfContents");
@ -111,22 +120,13 @@ describe("File", () => {
expect(spy.called).to.equal(true);
});
it("should call the underlying document's addImage", () => {
const wrapper = new File();
const spy = sinon.spy(wrapper.Document, "addParagraph");
// tslint:disable-next-line:no-any
wrapper.add(new Paragraph(""));
expect(spy.called).to.equal(true);
});
});
describe("#createImage", () => {
it("should call the underlying document's createImage", () => {
const wrapper = new File();
const spy = sinon.spy(wrapper.Media, "addMedia");
const wrapperSpy = sinon.spy(wrapper.Document, "addParagraph");
const wrapperSpy = sinon.spy(wrapper.Document, "add");
wrapper.createImage("");
expect(spy.called).to.equal(true);