add support for floating drawings
- added need elements and test for them
This commit is contained in:
@ -2,14 +2,12 @@ import { assert } from "chai";
|
||||
import * as fs from "fs";
|
||||
|
||||
import { Utility } from "../../tests/utility";
|
||||
import { Drawing } from "./";
|
||||
import { Drawing, DrawingOptions, PlacementPosition } from "./";
|
||||
|
||||
describe("Drawing", () => {
|
||||
let currentBreak: Drawing;
|
||||
|
||||
beforeEach(() => {
|
||||
const path = "./demo/images/image1.jpeg";
|
||||
currentBreak = new Drawing({
|
||||
function createDrawing(drawingOptions?: DrawingOptions) {
|
||||
const path = "./demo/images/image1.jpeg";
|
||||
return new Drawing(
|
||||
{
|
||||
fileName: "test.jpg",
|
||||
referenceId: 1,
|
||||
stream: fs.createReadStream(path),
|
||||
@ -24,14 +22,33 @@ describe("Drawing", () => {
|
||||
y: 100 * 9525,
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
},
|
||||
drawingOptions,
|
||||
);
|
||||
}
|
||||
|
||||
describe("Drawing", () => {
|
||||
let currentBreak: Drawing;
|
||||
|
||||
describe("#constructor()", () => {
|
||||
it("should create a Drawing with correct root key", () => {
|
||||
currentBreak = createDrawing();
|
||||
const newJson = Utility.jsonify(currentBreak);
|
||||
assert.equal(newJson.rootKey, "w:drawing");
|
||||
// console.log(JSON.stringify(newJson, null, 2));
|
||||
});
|
||||
|
||||
it("should create a drawing with inline element when there are no options passed", () => {
|
||||
currentBreak = createDrawing();
|
||||
const newJson = Utility.jsonify(currentBreak);
|
||||
assert.equal(newJson.root[0].rootKey, "wp:inline");
|
||||
});
|
||||
|
||||
it("should create a drawing with anchor element when there options are passed", () => {
|
||||
currentBreak = createDrawing({
|
||||
position: PlacementPosition.FLOATING,
|
||||
});
|
||||
const newJson = Utility.jsonify(currentBreak);
|
||||
assert.equal(newJson.root[0].rootKey, "wp:anchor");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user