Files
docx-js/src/patcher/relationship-manager.spec.ts
dependabot[bot] 2381ba8a05 build(deps-dev): bump eslint from 8.57.1 to 9.13.0 (#2792)
* build(deps-dev): bump eslint from 8.57.1 to 9.13.0

Bumps [eslint](https://github.com/eslint/eslint) from 8.57.1 to 9.13.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v8.57.1...v9.13.0)

---
updated-dependencies:
- dependency-name: eslint
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* Upgrade EsLint

* Fix all new lint errors

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dolan Miu <dolan_miu@hotmail.com>
2024-10-21 03:57:15 +01:00

89 lines
3.2 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { TargetModeType } from "@file/relationships/relationship/relationship";
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);
});
it("should work with an empty relationship Id", () => {
const output = getNextRelationshipIndex({
elements: [
{
type: "element",
name: "Relationships",
elements: [{ type: "element", name: "Relationship" }],
},
],
});
expect(output).to.deep.equal(1);
});
it("should work with no relationships", () => {
const output = getNextRelationshipIndex({
elements: [
{
type: "element",
name: "Relationships",
elements: [],
},
],
});
expect(output).to.deep.equal(1);
});
});
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",
},
]);
});
});
});