2016-07-01 22:09:55 +01:00
|
|
|
/// <reference path="../../../typings/mocha/mocha.d.ts" />
|
|
|
|
/// <reference path="../../../typings/chai/chai.d.ts" />
|
|
|
|
|
|
|
|
import {Run} from "../../../docx/run";
|
|
|
|
import {TextRun} from "../../../docx/run/text-run";
|
2016-03-30 03:58:53 +01:00
|
|
|
import {assert} from "chai";
|
|
|
|
|
|
|
|
function jsonify(obj: Object) {
|
2016-05-26 15:08:34 +01:00
|
|
|
let stringifiedJson = JSON.stringify(obj);
|
2016-03-30 03:58:53 +01:00
|
|
|
return JSON.parse(stringifiedJson);
|
|
|
|
}
|
|
|
|
|
2016-04-03 05:24:56 +01:00
|
|
|
describe("Run", () => {
|
2016-05-26 15:08:34 +01:00
|
|
|
let run: Run;
|
2016-03-30 03:58:53 +01:00
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
run = new Run();
|
|
|
|
});
|
|
|
|
|
2016-05-26 15:08:34 +01:00
|
|
|
describe("#bold()", () => {
|
2016-03-30 04:43:56 +01:00
|
|
|
it("it should add bold to the properties", () => {
|
|
|
|
run.bold();
|
2016-05-26 15:08:34 +01:00
|
|
|
let newJson = jsonify(run);
|
2016-05-02 22:39:03 +01:00
|
|
|
assert.equal(newJson.root[0].root[0].rootKey, "w:b");
|
2016-03-30 04:43:56 +01:00
|
|
|
});
|
|
|
|
});
|
2016-03-30 03:58:53 +01:00
|
|
|
|
2016-05-26 15:08:34 +01:00
|
|
|
describe("#italic()", () => {
|
2016-03-30 04:43:56 +01:00
|
|
|
it("it should add italics to the properties", () => {
|
2016-05-24 21:37:58 +01:00
|
|
|
run.italic();
|
2016-05-26 15:08:34 +01:00
|
|
|
let newJson = jsonify(run);
|
2016-05-02 22:39:03 +01:00
|
|
|
assert.equal(newJson.root[0].root[0].rootKey, "w:i");
|
2016-03-30 04:43:56 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-05-26 15:08:34 +01:00
|
|
|
describe("#underline()", () => {
|
2016-03-30 04:43:56 +01:00
|
|
|
it("it should add underline to the properties", () => {
|
|
|
|
run.underline();
|
2016-05-26 15:08:34 +01:00
|
|
|
let newJson = jsonify(run);
|
2016-05-02 22:39:03 +01:00
|
|
|
assert.equal(newJson.root[0].root[0].rootKey, "w:u");
|
2016-03-30 03:58:53 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-05-26 15:08:34 +01:00
|
|
|
describe("TextRun", () => {
|
|
|
|
let run: TextRun;
|
2016-03-30 03:58:53 +01:00
|
|
|
|
2016-05-26 15:08:34 +01:00
|
|
|
describe("#constructor()", () => {
|
2016-03-30 03:58:53 +01:00
|
|
|
|
|
|
|
it("should add text into run", () => {
|
|
|
|
run = new TextRun("test");
|
2016-05-26 15:08:34 +01:00
|
|
|
let newJson = jsonify(run);
|
2016-05-02 22:39:03 +01:00
|
|
|
assert.equal(newJson.root[1].root, "test");
|
2016-03-30 03:58:53 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|