Add tests
This commit is contained in:
61
src/patcher/relationship-manager.spec.ts
Normal file
61
src/patcher/relationship-manager.spec.ts
Normal 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",
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user