Files
docx-js/ts/tests/docx/run/runTest.ts

89 lines
2.6 KiB
TypeScript
Raw Normal View History

2017-03-08 20:28:59 +01:00
import { assert } from "chai";
import { Run } from "../../../docx/run";
import { TextRun } from "../../../docx/run/text-run";
2017-03-08 20:28:59 +01:00
import { Formatter } from "../../../export/formatter";
2016-03-30 03:58:53 +01:00
2017-03-08 20:28:59 +01:00
function jsonify(obj: object) {
return JSON.parse(JSON.stringify(obj));
2016-03-30 03:58:53 +01:00
}
2016-07-13 00:59:53 +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();
2017-03-08 20:28:59 +01:00
const 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();
2017-03-08 20:28:59 +01:00
const 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();
2017-03-08 20:28:59 +01:00
const 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-07-12 08:46:26 +01:00
describe("#smallCaps()", () => {
it("it should add smallCaps to the properties", () => {
run.smallCaps();
2017-03-08 20:28:59 +01:00
const newJson = jsonify(run);
2016-07-12 08:46:26 +01:00
assert.equal(newJson.root[0].root[0].rootKey, "w:smallCaps");
});
});
describe("#caps()", () => {
it("it should add caps to the properties", () => {
run.allCaps();
2017-03-08 20:28:59 +01:00
const newJson = jsonify(run);
2016-07-12 08:46:26 +01:00
assert.equal(newJson.root[0].root[0].rootKey, "w:caps");
});
});
describe("#strike()", () => {
it("it should add strike to the properties", () => {
run.strike();
2017-03-08 20:28:59 +01:00
const newJson = jsonify(run);
2016-07-12 08:46:26 +01:00
assert.equal(newJson.root[0].root[0].rootKey, "w:strike");
});
});
2016-03-30 03:58:53 +01:00
2016-07-12 08:46:26 +01:00
describe("#doubleStrike()", () => {
it("it should add caps to the properties", () => {
run.doubleStrike();
2017-03-08 20:28:59 +01:00
const newJson = jsonify(run);
2016-07-12 08:46:26 +01:00
assert.equal(newJson.root[0].root[0].rootKey, "w:dstrike");
});
});
describe("#break()", () => {
it("it should add break to the run", () => {
run.break();
2017-03-08 20:28:59 +01:00
const newJson = jsonify(run);
2016-07-12 08:46:26 +01:00
assert.equal(newJson.root[1].rootKey, "w:br");
});
});
2016-03-30 03:58:53 +01:00
2016-07-12 08:46:26 +01:00
describe("#tab()", () => {
it("it should add break to the run", () => {
run.tab();
2017-03-08 20:28:59 +01:00
const newJson = jsonify(run);
2016-07-12 08:46:26 +01:00
assert.equal(newJson.root[1].rootKey, "w:tab");
2016-03-30 03:58:53 +01:00
});
});
2017-03-08 20:28:59 +01:00
});