2017-03-13 00:02:56 +00:00
|
|
|
import { assert } from "chai";
|
2018-08-10 02:46:15 +01:00
|
|
|
import * as fs from "fs";
|
2017-09-17 00:00:41 +01:00
|
|
|
|
2017-12-19 23:13:11 +00:00
|
|
|
import { Utility } from "../../tests/utility";
|
2018-06-09 23:49:01 +01:00
|
|
|
import { Drawing, IDrawingOptions, PlacementPosition } from "./";
|
2017-03-12 23:32:02 +00:00
|
|
|
|
2018-06-09 23:49:01 +01:00
|
|
|
function createDrawing(drawingOptions?: IDrawingOptions): Drawing {
|
2018-06-08 16:03:04 +02:00
|
|
|
const path = "./demo/images/image1.jpeg";
|
|
|
|
return new Drawing(
|
|
|
|
{
|
2017-04-01 12:30:27 +01:00
|
|
|
fileName: "test.jpg",
|
|
|
|
referenceId: 1,
|
2018-08-10 02:46:15 +01:00
|
|
|
stream: fs.createReadStream(path),
|
2017-04-01 12:30:27 +01:00
|
|
|
path: path,
|
2018-01-22 20:42:57 +00:00
|
|
|
dimensions: {
|
|
|
|
pixels: {
|
|
|
|
x: 100,
|
|
|
|
y: 100,
|
|
|
|
},
|
|
|
|
emus: {
|
|
|
|
x: 100 * 9525,
|
|
|
|
y: 100 * 9525,
|
|
|
|
},
|
|
|
|
},
|
2018-06-08 16:03:04 +02:00
|
|
|
},
|
|
|
|
drawingOptions,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
describe("Drawing", () => {
|
|
|
|
let currentBreak: Drawing;
|
2017-03-12 23:32:02 +00:00
|
|
|
|
|
|
|
describe("#constructor()", () => {
|
|
|
|
it("should create a Drawing with correct root key", () => {
|
2018-06-08 16:03:04 +02:00
|
|
|
currentBreak = createDrawing();
|
2017-03-12 23:32:02 +00:00
|
|
|
const newJson = Utility.jsonify(currentBreak);
|
|
|
|
assert.equal(newJson.rootKey, "w:drawing");
|
2018-06-08 16:03:04 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
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");
|
2017-03-12 23:32:02 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|