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

215 lines
6.7 KiB
TypeScript
Raw Normal View History

import { assert, expect } from "chai";
import * as u from "../../../docx/run/underline";
import { Formatter } from "../../../export/formatter";
2017-03-09 22:56:08 +00:00
import { Utility } from "../../utility";
2016-07-13 00:59:53 +01:00
2016-07-13 18:49:02 +01:00
describe("Underline", () => {
2016-07-13 00:59:53 +01:00
describe("#constructor()", () => {
2016-07-13 18:49:02 +01:00
it("should create a new Underline object with u:u as the rootKey", () => {
const underline = new u.Underline();
2017-03-09 22:56:08 +00:00
const newJson = Utility.jsonify(underline);
2016-07-13 00:59:53 +01:00
assert.equal(newJson.rootKey, "w:u");
});
it("should default to 'single' and no color", () => {
const underline = new u.Underline();
const tree = new Formatter().format(underline);
expect(tree).to.deep.equal({
"w:u": [{_attr: {"w:val": "single"}}],
});
});
it("should use the given style type and color", () => {
const underline = new u.Underline("double", "FF00CC");
const tree = new Formatter().format(underline);
expect(tree).to.deep.equal({
"w:u": [{_attr: {"w:val": "double", "w:color": "FF00CC"}}],
});
});
2016-07-13 00:59:53 +01:00
});
});
2016-07-15 18:50:54 +01:00
describe("DashDotDotHeavyUnderline", () => {
2016-07-13 00:59:53 +01:00
describe("#constructor()", () => {
2016-07-13 18:49:02 +01:00
it("should have u:u as the rootKey", () => {
const underline = new u.DashDotDotHeavyUnderline();
2017-03-09 22:56:08 +00:00
const newJson = Utility.jsonify(underline);
2016-07-13 00:59:53 +01:00
assert.equal(newJson.rootKey, "w:u");
});
2016-07-13 18:49:02 +01:00
it("should put value in attribute", () => {
const underline = new u.DashDotDotHeavyUnderline();
2017-03-09 22:56:08 +00:00
const newJson = Utility.jsonify(underline);
2016-07-13 18:49:02 +01:00
assert.equal(newJson.root[0].root.val, "dashDotDotHeavy");
});
});
});
2016-07-15 18:50:54 +01:00
describe("DashDotDotHeavyUnderline", () => {
2016-07-13 18:49:02 +01:00
describe("#constructor()", () => {
it("should put value in attribute", () => {
const underline = new u.DashDotHeavyUnderline();
2017-03-09 22:56:08 +00:00
const newJson = Utility.jsonify(underline);
2016-07-13 18:49:02 +01:00
assert.equal(newJson.root[0].root.val, "dashDotHeavy");
2016-07-13 00:59:53 +01:00
});
});
});
2016-07-13 18:49:02 +01:00
2016-07-15 18:50:54 +01:00
describe("DashDotDotHeavyUnderline", () => {
2016-07-13 18:49:02 +01:00
describe("#constructor()", () => {
it("should put value in attribute", () => {
const underline = new u.DashLongHeavyUnderline();
2017-03-09 22:56:08 +00:00
const newJson = Utility.jsonify(underline);
2016-07-13 18:49:02 +01:00
assert.equal(newJson.root[0].root.val, "dashLongHeavy");
});
});
});
2016-07-15 18:50:54 +01:00
describe("DashDotDotHeavyUnderline", () => {
2016-07-13 18:49:02 +01:00
describe("#constructor()", () => {
it("should put value in attribute", () => {
const underline = new u.DashLongUnderline();
2017-03-09 22:56:08 +00:00
const newJson = Utility.jsonify(underline);
2016-07-13 18:49:02 +01:00
assert.equal(newJson.root[0].root.val, "dashLong");
});
});
});
2016-07-15 18:50:54 +01:00
describe("DashDotDotHeavyUnderline", () => {
2016-07-13 18:49:02 +01:00
describe("#constructor()", () => {
it("should put value in attribute", () => {
const underline = new u.DashUnderline();
2017-03-09 22:56:08 +00:00
const newJson = Utility.jsonify(underline);
2016-07-13 18:49:02 +01:00
assert.equal(newJson.root[0].root.val, "dash");
});
});
});
2016-07-15 18:50:54 +01:00
describe("DashDotDotHeavyUnderline", () => {
2016-07-13 18:49:02 +01:00
describe("#constructor()", () => {
it("should put value in attribute", () => {
const underline = new u.DotDashUnderline();
2017-03-09 22:56:08 +00:00
const newJson = Utility.jsonify(underline);
2016-07-13 18:49:02 +01:00
assert.equal(newJson.root[0].root.val, "dotDash");
});
});
});
2016-07-15 18:50:54 +01:00
describe("DashDotDotHeavyUnderline", () => {
2016-07-13 18:49:02 +01:00
describe("#constructor()", () => {
it("should put value in attribute", () => {
const underline = new u.DotDotDashUnderline();
2017-03-09 22:56:08 +00:00
const newJson = Utility.jsonify(underline);
2016-07-13 18:49:02 +01:00
assert.equal(newJson.root[0].root.val, "dotDotDash");
});
});
});
2016-07-15 18:50:54 +01:00
describe("DashDotDotHeavyUnderline", () => {
2016-07-13 18:49:02 +01:00
describe("#constructor()", () => {
it("should put value in attribute", () => {
const underline = new u.DottedHeavyUnderline();
2017-03-09 22:56:08 +00:00
const newJson = Utility.jsonify(underline);
2016-07-13 18:49:02 +01:00
assert.equal(newJson.root[0].root.val, "dottedHeavy");
});
});
});
2016-07-15 18:50:54 +01:00
describe("DashDotDotHeavyUnderline", () => {
2016-07-13 18:49:02 +01:00
describe("#constructor()", () => {
it("should put value in attribute", () => {
const underline = new u.DottedUnderline();
2017-03-09 22:56:08 +00:00
const newJson = Utility.jsonify(underline);
2016-07-13 18:49:02 +01:00
assert.equal(newJson.root[0].root.val, "dotted");
});
});
});
2016-07-15 18:50:54 +01:00
describe("DashDotDotHeavyUnderline", () => {
2016-07-13 18:49:02 +01:00
describe("#constructor()", () => {
it("should put value in attribute", () => {
const underline = new u.DoubleUnderline();
2017-03-09 22:56:08 +00:00
const newJson = Utility.jsonify(underline);
2016-07-13 18:49:02 +01:00
assert.equal(newJson.root[0].root.val, "double");
});
});
});
2016-07-15 18:50:54 +01:00
describe("DashDotDotHeavyUnderline", () => {
2016-07-13 18:49:02 +01:00
describe("#constructor()", () => {
it("should put value in attribute", () => {
const underline = new u.SingleUnderline();
2017-03-09 22:56:08 +00:00
const newJson = Utility.jsonify(underline);
2016-07-13 18:49:02 +01:00
assert.equal(newJson.root[0].root.val, "single");
});
});
});
2016-07-15 18:50:54 +01:00
describe("DashDotDotHeavyUnderline", () => {
2016-07-13 18:49:02 +01:00
describe("#constructor()", () => {
it("should put value in attribute", () => {
const underline = new u.ThickUnderline();
2017-03-09 22:56:08 +00:00
const newJson = Utility.jsonify(underline);
2016-07-13 18:49:02 +01:00
assert.equal(newJson.root[0].root.val, "thick");
});
});
});
2016-07-15 18:50:54 +01:00
describe("DashDotDotHeavyUnderline", () => {
2016-07-13 18:49:02 +01:00
describe("#constructor()", () => {
it("should put value in attribute", () => {
const underline = new u.WaveUnderline();
2017-03-09 22:56:08 +00:00
const newJson = Utility.jsonify(underline);
2016-07-13 18:49:02 +01:00
assert.equal(newJson.root[0].root.val, "wave");
});
});
});
2016-07-15 18:50:54 +01:00
describe("DashDotDotHeavyUnderline", () => {
2016-07-13 18:49:02 +01:00
describe("#constructor()", () => {
it("should put value in attribute", () => {
const underline = new u.WavyDoubleUnderline();
2017-03-09 22:56:08 +00:00
const newJson = Utility.jsonify(underline);
2016-07-13 18:49:02 +01:00
assert.equal(newJson.root[0].root.val, "wavyDouble");
});
});
});
2016-07-15 18:50:54 +01:00
describe("DashDotDotHeavyUnderline", () => {
2016-07-13 18:49:02 +01:00
describe("#constructor()", () => {
it("should put value in attribute", () => {
const underline = new u.WavyHeavyUnderline();
2017-03-09 22:56:08 +00:00
const newJson = Utility.jsonify(underline);
2016-07-13 18:49:02 +01:00
assert.equal(newJson.root[0].root.val, "wavyHeavy");
});
});
});
2016-07-15 18:50:54 +01:00
describe("DashDotDotHeavyUnderline", () => {
2016-07-13 18:49:02 +01:00
describe("#constructor()", () => {
it("should put value in attribute", () => {
const underline = new u.WordsUnderline();
2017-03-09 22:56:08 +00:00
const newJson = Utility.jsonify(underline);
2016-07-13 18:49:02 +01:00
assert.equal(newJson.root[0].root.val, "words");
});
});
});