Remove usage of Utility
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 { PageBreak, PageBreakBefore } from "./page-break";
|
||||
|
||||
@ -13,21 +13,18 @@ describe("PageBreak", () => {
|
||||
|
||||
describe("#constructor()", () => {
|
||||
it("should create a Page Break with correct attributes", () => {
|
||||
const newJson = Utility.jsonify(pageBreak);
|
||||
const attributes = {
|
||||
type: "page",
|
||||
};
|
||||
assert.equal(JSON.stringify(newJson.root[1].root[0].root), JSON.stringify(attributes));
|
||||
});
|
||||
|
||||
it("should create a Page Break with w:r", () => {
|
||||
const newJson = Utility.jsonify(pageBreak);
|
||||
assert.equal(newJson.rootKey, "w:r");
|
||||
});
|
||||
|
||||
it("should create a Page Break with a Break inside", () => {
|
||||
const newJson = Utility.jsonify(pageBreak);
|
||||
assert.equal(newJson.root[1].rootKey, "w:br");
|
||||
const tree = new Formatter().format(pageBreak);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:r": [
|
||||
{
|
||||
"w:br": {
|
||||
_attr: {
|
||||
"w:type": "page",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -35,7 +32,9 @@ describe("PageBreak", () => {
|
||||
describe("PageBreakBefore", () => {
|
||||
it("should create page break before", () => {
|
||||
const pageBreakBefore = new PageBreakBefore();
|
||||
const newJson = Utility.jsonify(pageBreakBefore);
|
||||
assert.equal(newJson.rootKey, "w:pageBreakBefore");
|
||||
const tree = new Formatter().format(pageBreakBefore);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:pageBreakBefore": {},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { assert } from "chai";
|
||||
import { expect } from "chai";
|
||||
|
||||
import { Utility } from "tests/utility";
|
||||
import { Formatter } from "export/formatter";
|
||||
|
||||
import { NumberProperties } from "./unordered-list";
|
||||
|
||||
@ -13,20 +13,25 @@ describe("NumberProperties", () => {
|
||||
|
||||
describe("#constructor()", () => {
|
||||
it("should create a Number Properties with correct root key", () => {
|
||||
const newJson = Utility.jsonify(numberProperties);
|
||||
assert.equal(newJson.rootKey, "w:numPr");
|
||||
});
|
||||
|
||||
it("should create a Page Break with a Indent Level inside", () => {
|
||||
const newJson = Utility.jsonify(numberProperties);
|
||||
assert.equal(newJson.root[0].rootKey, "w:ilvl");
|
||||
assert.equal(newJson.root[0].root[0].root.val, 10);
|
||||
});
|
||||
|
||||
it("should create a Page Break with a Number Id inside", () => {
|
||||
const newJson = Utility.jsonify(numberProperties);
|
||||
assert.equal(newJson.root[1].rootKey, "w:numId");
|
||||
assert.equal(newJson.root[1].root[0].root.val, 5);
|
||||
const tree = new Formatter().format(numberProperties);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:numPr": [
|
||||
{
|
||||
"w:ilvl": {
|
||||
_attr: {
|
||||
"w:val": 10,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:numId": {
|
||||
_attr: {
|
||||
"w:val": 5,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { assert, expect } from "chai";
|
||||
import { expect } from "chai";
|
||||
|
||||
import { Formatter } from "export/formatter";
|
||||
import { Utility } from "tests/utility";
|
||||
|
||||
import { Hyperlink } from "./";
|
||||
|
||||
@ -14,28 +13,23 @@ describe("Hyperlink", () => {
|
||||
|
||||
describe("#constructor()", () => {
|
||||
it("should create a hyperlink with correct root key", () => {
|
||||
const newJson = Utility.jsonify(hyperlink);
|
||||
assert.equal(newJson.rootKey, "w:hyperlink");
|
||||
});
|
||||
|
||||
it("should create a hyperlink with right attributes", () => {
|
||||
const newJson = Utility.jsonify(hyperlink);
|
||||
const attributes = {
|
||||
history: 1,
|
||||
id: "rId1",
|
||||
};
|
||||
assert.equal(JSON.stringify(newJson.root[0].root), JSON.stringify(attributes));
|
||||
});
|
||||
|
||||
it("should create a hyperlink with a run component", () => {
|
||||
const tree = new Formatter().format(hyperlink);
|
||||
const runJson = {
|
||||
"w:r": [
|
||||
{ "w:rPr": [{ "w:rStyle": { _attr: { "w:val": "Hyperlink" } } }] },
|
||||
{ "w:t": [{ _attr: { "xml:space": "preserve" } }, "https://example.com"] },
|
||||
expect(tree).to.deep.equal({
|
||||
"w:hyperlink": [
|
||||
{
|
||||
_attr: {
|
||||
"w:history": 1,
|
||||
"r:id": "rId1",
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:r": [
|
||||
{ "w:rPr": [{ "w:rStyle": { _attr: { "w:val": "Hyperlink" } } }] },
|
||||
{ "w:t": [{ _attr: { "xml:space": "preserve" } }, "https://example.com"] },
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
expect(tree["w:hyperlink"][1]).to.deep.equal(runJson);
|
||||
});
|
||||
});
|
||||
|
||||
describe("with optional anchor parameter", () => {
|
||||
@ -44,12 +38,23 @@ describe("Hyperlink", () => {
|
||||
});
|
||||
|
||||
it("should create an internal link with anchor tag", () => {
|
||||
const newJson = Utility.jsonify(hyperlink);
|
||||
const attributes = {
|
||||
history: 1,
|
||||
anchor: "anchor",
|
||||
};
|
||||
assert.equal(JSON.stringify(newJson.root[0].root), JSON.stringify(attributes));
|
||||
const tree = new Formatter().format(hyperlink);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:hyperlink": [
|
||||
{
|
||||
_attr: {
|
||||
"w:history": 1,
|
||||
"w:anchor": "anchor",
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:r": [
|
||||
{ "w:rPr": [{ "w:rStyle": { _attr: { "w:val": "Hyperlink" } } }] },
|
||||
{ "w:t": [{ _attr: { "xml:space": "preserve" } }, "Anchor Text"] },
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user