Merge branch 'master' into feat/declaritive
# Conflicts: # src/file/paragraph/formatting/border.spec.ts # src/file/paragraph/links/outline-level.spec.ts # src/file/paragraph/run/run.spec.ts
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import { assert } from "chai";
|
||||
import { expect } from "chai";
|
||||
|
||||
import { Utility } from "tests/utility";
|
||||
import { Formatter } from "export/formatter";
|
||||
|
||||
import { Break } from "./break";
|
||||
|
||||
@ -13,8 +13,10 @@ describe("Break", () => {
|
||||
|
||||
describe("#constructor()", () => {
|
||||
it("should create a Break with correct root key", () => {
|
||||
const newJson = Utility.jsonify(currentBreak);
|
||||
assert.equal(newJson.rootKey, "w:br");
|
||||
const tree = new Formatter().format(currentBreak);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:br": {},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { assert, expect } from "chai";
|
||||
import { expect } from "chai";
|
||||
|
||||
import { Formatter } from "export/formatter";
|
||||
import { Utility } from "tests/utility";
|
||||
|
||||
import { Run } from "./";
|
||||
import { UnderlineType } from "./underline";
|
||||
@ -12,9 +11,23 @@ describe("Run", () => {
|
||||
const run = new Run({
|
||||
bold: true,
|
||||
});
|
||||
const newJson = Utility.jsonify(run);
|
||||
assert.equal(newJson.root[0].root[0].rootKey, "w:b");
|
||||
assert.equal(newJson.root[0].root[1].rootKey, "w:bCs");
|
||||
const tree = new Formatter().format(run);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:r": [
|
||||
{
|
||||
"w:rPr": [
|
||||
{ "w:b": { _attr: { "w:val": true } } },
|
||||
{
|
||||
"w:bCs": {
|
||||
_attr: {
|
||||
"w:val": true,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -23,9 +36,23 @@ describe("Run", () => {
|
||||
const run = new Run({
|
||||
italics: true,
|
||||
});
|
||||
const newJson = Utility.jsonify(run);
|
||||
assert.equal(newJson.root[0].root[0].rootKey, "w:i");
|
||||
assert.equal(newJson.root[0].root[1].rootKey, "w:iCs");
|
||||
const tree = new Formatter().format(run);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:r": [
|
||||
{
|
||||
"w:rPr": [
|
||||
{ "w:i": { _attr: { "w:val": true } } },
|
||||
{
|
||||
"w:iCs": {
|
||||
_attr: {
|
||||
"w:val": true,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -59,8 +86,10 @@ describe("Run", () => {
|
||||
const run = new Run({
|
||||
smallCaps: true,
|
||||
});
|
||||
const newJson = Utility.jsonify(run);
|
||||
assert.equal(newJson.root[0].root[0].rootKey, "w:smallCaps");
|
||||
const tree = new Formatter().format(run);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:r": [{ "w:rPr": [{ "w:smallCaps": {} }] }],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -69,8 +98,10 @@ describe("Run", () => {
|
||||
const run = new Run({
|
||||
allCaps: true,
|
||||
});
|
||||
const newJson = Utility.jsonify(run);
|
||||
assert.equal(newJson.root[0].root[0].rootKey, "w:caps");
|
||||
const tree = new Formatter().format(run);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:r": [{ "w:rPr": [{ "w:caps": {} }] }],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -79,8 +110,10 @@ describe("Run", () => {
|
||||
const run = new Run({
|
||||
strike: true,
|
||||
});
|
||||
const newJson = Utility.jsonify(run);
|
||||
assert.equal(newJson.root[0].root[0].rootKey, "w:strike");
|
||||
const tree = new Formatter().format(run);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:r": [{ "w:rPr": [{ "w:strike": { _attr: { "w:val": true } } }] }],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -89,8 +122,10 @@ describe("Run", () => {
|
||||
const run = new Run({
|
||||
doubleStrike: true,
|
||||
});
|
||||
const newJson = Utility.jsonify(run);
|
||||
assert.equal(newJson.root[0].root[0].rootKey, "w:dstrike");
|
||||
const tree = new Formatter().format(run);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:r": [{ "w:rPr": [{ "w:dstrike": { _attr: { "w:val": true } } }] }],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -98,8 +133,10 @@ describe("Run", () => {
|
||||
it("it should add break to the run", () => {
|
||||
const run = new Run({});
|
||||
run.break();
|
||||
const newJson = Utility.jsonify(run);
|
||||
assert.equal(newJson.root[1].rootKey, "w:br");
|
||||
const tree = new Formatter().format(run);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:r": [{ "w:br": {} }],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -107,8 +144,10 @@ describe("Run", () => {
|
||||
it("it should add break to the run", () => {
|
||||
const run = new Run({});
|
||||
run.tab();
|
||||
const newJson = Utility.jsonify(run);
|
||||
assert.equal(newJson.root[1].rootKey, "w:tab");
|
||||
const tree = new Formatter().format(run);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:r": [{ "w:tab": {} }],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { assert } from "chai";
|
||||
import { expect } from "chai";
|
||||
|
||||
import { Utility } from "tests/utility";
|
||||
import { Formatter } from "export/formatter";
|
||||
|
||||
import { DoubleStrike, Strike } from "./formatting";
|
||||
|
||||
@ -13,8 +13,14 @@ describe("Strike", () => {
|
||||
|
||||
describe("#constructor()", () => {
|
||||
it("should create a Strike with correct root key", () => {
|
||||
const newJson = Utility.jsonify(strike);
|
||||
assert.equal(newJson.rootKey, "w:strike");
|
||||
const tree = new Formatter().format(strike);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:strike": {
|
||||
_attr: {
|
||||
"w:val": true,
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -28,8 +34,14 @@ describe("DoubleStrike", () => {
|
||||
|
||||
describe("#constructor()", () => {
|
||||
it("should create a Double Strike with correct root key", () => {
|
||||
const newJson = Utility.jsonify(strike);
|
||||
assert.equal(newJson.rootKey, "w:dstrike");
|
||||
const tree = new Formatter().format(strike);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:dstrike": {
|
||||
_attr: {
|
||||
"w:val": true,
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { assert } from "chai";
|
||||
import { expect } from "chai";
|
||||
|
||||
import { Utility } from "tests/utility";
|
||||
import { Formatter } from "export/formatter";
|
||||
|
||||
import { Tab } from "./tab";
|
||||
|
||||
@ -13,8 +13,10 @@ describe("Tab", () => {
|
||||
|
||||
describe("#constructor()", () => {
|
||||
it("should create a Tab with correct root key", () => {
|
||||
const newJson = Utility.jsonify(tab);
|
||||
assert.equal(newJson.rootKey, "w:tab");
|
||||
const tree = new Formatter().format(tab);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:tab": {},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { assert, expect } from "chai";
|
||||
import { expect } from "chai";
|
||||
|
||||
import { Formatter } from "export/formatter";
|
||||
import { Utility } from "tests/utility";
|
||||
|
||||
import * as u from "./underline";
|
||||
|
||||
@ -9,8 +8,14 @@ describe("Underline", () => {
|
||||
describe("#constructor()", () => {
|
||||
it("should create a new Underline object with u:u as the rootKey", () => {
|
||||
const underline = new u.Underline();
|
||||
const newJson = Utility.jsonify(underline);
|
||||
assert.equal(newJson.rootKey, "w:u");
|
||||
const tree = new Formatter().format(underline);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:u": {
|
||||
_attr: {
|
||||
"w:val": "single",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("should default to 'single' and no color", () => {
|
||||
@ -33,16 +38,16 @@ describe("Underline", () => {
|
||||
|
||||
describe("DashDotDotHeavyUnderline", () => {
|
||||
describe("#constructor()", () => {
|
||||
it("should have u:u as the rootKey", () => {
|
||||
const underline = new u.DashDotDotHeavyUnderline();
|
||||
const newJson = Utility.jsonify(underline);
|
||||
assert.equal(newJson.rootKey, "w:u");
|
||||
});
|
||||
|
||||
it("should put value in attribute", () => {
|
||||
const underline = new u.DashDotDotHeavyUnderline();
|
||||
const newJson = Utility.jsonify(underline);
|
||||
assert.equal(newJson.root[0].root.val, "dashDotDotHeavy");
|
||||
const tree = new Formatter().format(underline);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:u": {
|
||||
_attr: {
|
||||
"w:val": "dashDotDotHeavy",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -51,8 +56,14 @@ describe("DashDotDotHeavyUnderline", () => {
|
||||
describe("#constructor()", () => {
|
||||
it("should put value in attribute", () => {
|
||||
const underline = new u.DashDotHeavyUnderline();
|
||||
const newJson = Utility.jsonify(underline);
|
||||
assert.equal(newJson.root[0].root.val, "dashDotHeavy");
|
||||
const tree = new Formatter().format(underline);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:u": {
|
||||
_attr: {
|
||||
"w:val": "dashDotHeavy",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -61,8 +72,14 @@ describe("DashDotDotHeavyUnderline", () => {
|
||||
describe("#constructor()", () => {
|
||||
it("should put value in attribute", () => {
|
||||
const underline = new u.DashLongHeavyUnderline();
|
||||
const newJson = Utility.jsonify(underline);
|
||||
assert.equal(newJson.root[0].root.val, "dashLongHeavy");
|
||||
const tree = new Formatter().format(underline);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:u": {
|
||||
_attr: {
|
||||
"w:val": "dashLongHeavy",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -71,8 +88,14 @@ describe("DashDotDotHeavyUnderline", () => {
|
||||
describe("#constructor()", () => {
|
||||
it("should put value in attribute", () => {
|
||||
const underline = new u.DashLongUnderline();
|
||||
const newJson = Utility.jsonify(underline);
|
||||
assert.equal(newJson.root[0].root.val, "dashLong");
|
||||
const tree = new Formatter().format(underline);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:u": {
|
||||
_attr: {
|
||||
"w:val": "dashLong",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -81,8 +104,14 @@ describe("DashDotDotHeavyUnderline", () => {
|
||||
describe("#constructor()", () => {
|
||||
it("should put value in attribute", () => {
|
||||
const underline = new u.DashUnderline();
|
||||
const newJson = Utility.jsonify(underline);
|
||||
assert.equal(newJson.root[0].root.val, "dash");
|
||||
const tree = new Formatter().format(underline);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:u": {
|
||||
_attr: {
|
||||
"w:val": "dash",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -91,8 +120,14 @@ describe("DashDotDotHeavyUnderline", () => {
|
||||
describe("#constructor()", () => {
|
||||
it("should put value in attribute", () => {
|
||||
const underline = new u.DotDashUnderline();
|
||||
const newJson = Utility.jsonify(underline);
|
||||
assert.equal(newJson.root[0].root.val, "dotDash");
|
||||
const tree = new Formatter().format(underline);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:u": {
|
||||
_attr: {
|
||||
"w:val": "dotDash",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -101,8 +136,14 @@ describe("DashDotDotHeavyUnderline", () => {
|
||||
describe("#constructor()", () => {
|
||||
it("should put value in attribute", () => {
|
||||
const underline = new u.DotDotDashUnderline();
|
||||
const newJson = Utility.jsonify(underline);
|
||||
assert.equal(newJson.root[0].root.val, "dotDotDash");
|
||||
const tree = new Formatter().format(underline);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:u": {
|
||||
_attr: {
|
||||
"w:val": "dotDotDash",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -111,8 +152,14 @@ describe("DashDotDotHeavyUnderline", () => {
|
||||
describe("#constructor()", () => {
|
||||
it("should put value in attribute", () => {
|
||||
const underline = new u.DottedHeavyUnderline();
|
||||
const newJson = Utility.jsonify(underline);
|
||||
assert.equal(newJson.root[0].root.val, "dottedHeavy");
|
||||
const tree = new Formatter().format(underline);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:u": {
|
||||
_attr: {
|
||||
"w:val": "dottedHeavy",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -121,8 +168,14 @@ describe("DashDotDotHeavyUnderline", () => {
|
||||
describe("#constructor()", () => {
|
||||
it("should put value in attribute", () => {
|
||||
const underline = new u.DottedUnderline();
|
||||
const newJson = Utility.jsonify(underline);
|
||||
assert.equal(newJson.root[0].root.val, "dotted");
|
||||
const tree = new Formatter().format(underline);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:u": {
|
||||
_attr: {
|
||||
"w:val": "dotted",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -131,8 +184,14 @@ describe("DashDotDotHeavyUnderline", () => {
|
||||
describe("#constructor()", () => {
|
||||
it("should put value in attribute", () => {
|
||||
const underline = new u.DoubleUnderline();
|
||||
const newJson = Utility.jsonify(underline);
|
||||
assert.equal(newJson.root[0].root.val, "double");
|
||||
const tree = new Formatter().format(underline);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:u": {
|
||||
_attr: {
|
||||
"w:val": "double",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -141,8 +200,14 @@ describe("DashDotDotHeavyUnderline", () => {
|
||||
describe("#constructor()", () => {
|
||||
it("should put value in attribute", () => {
|
||||
const underline = new u.SingleUnderline();
|
||||
const newJson = Utility.jsonify(underline);
|
||||
assert.equal(newJson.root[0].root.val, "single");
|
||||
const tree = new Formatter().format(underline);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:u": {
|
||||
_attr: {
|
||||
"w:val": "single",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -151,8 +216,14 @@ describe("DashDotDotHeavyUnderline", () => {
|
||||
describe("#constructor()", () => {
|
||||
it("should put value in attribute", () => {
|
||||
const underline = new u.ThickUnderline();
|
||||
const newJson = Utility.jsonify(underline);
|
||||
assert.equal(newJson.root[0].root.val, "thick");
|
||||
const tree = new Formatter().format(underline);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:u": {
|
||||
_attr: {
|
||||
"w:val": "thick",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -161,8 +232,14 @@ describe("DashDotDotHeavyUnderline", () => {
|
||||
describe("#constructor()", () => {
|
||||
it("should put value in attribute", () => {
|
||||
const underline = new u.WaveUnderline();
|
||||
const newJson = Utility.jsonify(underline);
|
||||
assert.equal(newJson.root[0].root.val, "wave");
|
||||
const tree = new Formatter().format(underline);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:u": {
|
||||
_attr: {
|
||||
"w:val": "wave",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -171,8 +248,14 @@ describe("DashDotDotHeavyUnderline", () => {
|
||||
describe("#constructor()", () => {
|
||||
it("should put value in attribute", () => {
|
||||
const underline = new u.WavyDoubleUnderline();
|
||||
const newJson = Utility.jsonify(underline);
|
||||
assert.equal(newJson.root[0].root.val, "wavyDouble");
|
||||
const tree = new Formatter().format(underline);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:u": {
|
||||
_attr: {
|
||||
"w:val": "wavyDouble",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -181,8 +264,14 @@ describe("DashDotDotHeavyUnderline", () => {
|
||||
describe("#constructor()", () => {
|
||||
it("should put value in attribute", () => {
|
||||
const underline = new u.WavyHeavyUnderline();
|
||||
const newJson = Utility.jsonify(underline);
|
||||
assert.equal(newJson.root[0].root.val, "wavyHeavy");
|
||||
const tree = new Formatter().format(underline);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:u": {
|
||||
_attr: {
|
||||
"w:val": "wavyHeavy",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -191,8 +280,14 @@ describe("DashDotDotHeavyUnderline", () => {
|
||||
describe("#constructor()", () => {
|
||||
it("should put value in attribute", () => {
|
||||
const underline = new u.WordsUnderline();
|
||||
const newJson = Utility.jsonify(underline);
|
||||
assert.equal(newJson.root[0].root.val, "words");
|
||||
const tree = new Formatter().format(underline);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:u": {
|
||||
_attr: {
|
||||
"w:val": "words",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user