Skip to content

Commit 139cfaa

Browse files
chore(refactor): clean-up path validation tests
1 parent 80c37c3 commit 139cfaa

1 file changed

Lines changed: 21 additions & 43 deletions

File tree

test/model/pathValidationUtils.test.ts

Lines changed: 21 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -33,36 +33,6 @@ describe("checkForCircularReference()", () => {
3333
});
3434

3535
describe("validatePaths()", () => {
36-
const elementsForLinkingGatewayAndItsChild = {
37-
a: { nextElements: [{ id: "b" }, { id: "c" }] },
38-
b: ref("c"),
39-
c: {}
40-
};
41-
const elementsForLinkingNeighbouringChildren = {
42-
a: { nextElements: [{ id: "b" }, { id: "c" }] },
43-
b: ref("d"),
44-
c: ref("d"),
45-
d: {}
46-
};
47-
const elementsForLinkingMultipleAncestorsOfNestedGateways = {
48-
a: { nextElements: [{ id: "b" }, { id: "c" }, { id: "d" }, { id: "e" }] },
49-
b: ref("bc"),
50-
c: ref("bc"),
51-
bc: ref("f"),
52-
d: ref("de"),
53-
e: ref("de"),
54-
de: ref("f"),
55-
f: {}
56-
};
57-
const elementsForLinkingNonNeighbouringPaths = {
58-
a: { nextElements: [{ id: "b" }, { id: "c" }, { id: "d" }, { id: "e" }] },
59-
b: ref("f"),
60-
c: {},
61-
d: ref("f"),
62-
e: ref("b"),
63-
f: {}
64-
};
65-
6636
describe.each`
6737
testDescription | firstElementId | additionalElements
6838
${"root"} | ${"a"} | ${{}}
@@ -74,7 +44,9 @@ describe("validatePaths()", () => {
7444
it("accepts link between diverging gateway and one of its children", () => {
7545
const elements = {
7646
...additionalElements,
77-
...elementsForLinkingGatewayAndItsChild
47+
a: { nextElements: [{ id: "b" }, { id: "c" }] },
48+
b: ref("c"),
49+
c: {}
7850
};
7951
const treeRootElement = createElementTree({ firstElementId, elements }, "top");
8052
const execution = (): never => validatePaths(treeRootElement);
@@ -83,7 +55,10 @@ describe("validatePaths()", () => {
8355
it("accepts link between neighbouring children of diverging gateway", () => {
8456
const elements = {
8557
...additionalElements,
86-
...elementsForLinkingNeighbouringChildren
58+
a: { nextElements: [{ id: "b" }, { id: "c" }] },
59+
b: ref("d"),
60+
c: ref("d"),
61+
d: {}
8762
};
8863
const treeRootElement = createElementTree({ firstElementId, elements }, "top");
8964
const execution = (): never => validatePaths(treeRootElement);
@@ -92,7 +67,14 @@ describe("validatePaths()", () => {
9267
it("accepts links between multiple ancestors of nested diverging gateways", () => {
9368
const elements = {
9469
...additionalElements,
95-
...elementsForLinkingMultipleAncestorsOfNestedGateways
70+
a: { nextElements: [{ id: "b" }, { id: "c" }, { id: "d" }, { id: "e" }] },
71+
b: ref("bc"),
72+
c: ref("bc"),
73+
bc: ref("f"),
74+
d: ref("de"),
75+
e: ref("de"),
76+
de: ref("f"),
77+
f: {}
9678
};
9779
const treeRootElement = createElementTree({ firstElementId, elements }, "top");
9880
const execution = (): never => validatePaths(treeRootElement);
@@ -101,16 +83,12 @@ describe("validatePaths()", () => {
10183
it("throws error for multiple references on non-neighbouring paths", () => {
10284
const elements = {
10385
...additionalElements,
104-
...elementsForLinkingNonNeighbouringPaths
105-
};
106-
const treeRootElement = createElementTree({ firstElementId, elements }, "top");
107-
const execution = (): never => validatePaths(treeRootElement);
108-
expect(execution).toThrowError("Multiple references only valid from neighbouring paths. Invalid references to: 'b', 'f'");
109-
});
110-
it("throws error for multiple references on non-neighbouring paths", () => {
111-
const elements = {
112-
...additionalElements,
113-
...elementsForLinkingNonNeighbouringPaths
86+
a: { nextElements: [{ id: "b" }, { id: "c" }, { id: "d" }, { id: "e" }] },
87+
b: ref("f"),
88+
c: {},
89+
d: ref("f"),
90+
e: ref("b"),
91+
f: {}
11492
};
11593
const treeRootElement = createElementTree({ firstElementId, elements }, "top");
11694
const execution = (): never => validatePaths(treeRootElement);

0 commit comments

Comments
 (0)