Add tests

This commit is contained in:
Dolan Miu
2023-03-15 02:46:39 +00:00
parent 352511bb55
commit 811dd61562
12 changed files with 1138 additions and 11 deletions

View File

@ -0,0 +1,61 @@
import { TargetModeType } from "@file/relationships/relationship/relationship";
import { expect } from "chai";
import { appendRelationship, getNextRelationshipIndex } from "./relationship-manager";
describe("relationship-manager", () => {
describe("getNextRelationshipIndex", () => {
it("should get next relationship index", () => {
const output = getNextRelationshipIndex({
elements: [
{
type: "element",
name: "Relationships",
elements: [
{ type: "element", attributes: { Id: "rId1" }, name: "Relationship" },
{ type: "element", attributes: { Id: "rId1" }, name: "Relationship" },
],
},
],
});
expect(output).to.deep.equal(2);
});
});
describe("appendRelationship", () => {
it("should append a relationship", () => {
const output = appendRelationship(
{
elements: [
{
type: "element",
name: "Relationships",
elements: [
{ type: "element", attributes: { Id: "rId1" }, name: "Relationship" },
{ type: "element", attributes: { Id: "rId1" }, name: "Relationship" },
],
},
],
},
1,
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
"test",
TargetModeType.EXTERNAL,
);
expect(output).to.deep.equal([
{ type: "element", attributes: { Id: "rId1" }, name: "Relationship" },
{ type: "element", attributes: { Id: "rId1" }, name: "Relationship" },
{
attributes: {
Id: "rId1",
Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
TargetMode: TargetModeType.EXTERNAL,
Target: "test",
},
name: "Relationship",
type: "element",
},
]);
});
});
});