Skip to content

Commit 8307d5b

Browse files
committed
Fix bug and add test
1 parent c792738 commit 8307d5b

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

dist/index.js

+3
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ class GraphBuilder {
110110
graphNode = { value: issue, predecessors: [], successors: [] };
111111
this.nodes.set(nodeKey, graphNode);
112112
}
113+
else if (issue) {
114+
graphNode.value = issue;
115+
}
113116
return graphNode;
114117
}
115118
addIssue(issueReference, issue) {

src/graph-builder.ts

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ export class GraphBuilder {
3333
if (!graphNode) {
3434
graphNode = { value: issue, predecessors: [], successors: [] };
3535
this.nodes.set(nodeKey, graphNode);
36+
} else if (issue) {
37+
graphNode.value = issue;
3638
}
3739

3840
return graphNode;

tests/graph-builder.test.ts

+25
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,29 @@ describe("GraphBuilder", () => {
197197
{ from: "issue3", to: "finish" },
198198
]);
199199
});
200+
201+
it("Add dependency before adding node", () => {
202+
const graphBuilder = new GraphBuilder(true);
203+
204+
graphBuilder.addIssue(
205+
{ repoOwner: "A", repoName: "B", issueNumber: 1 },
206+
new MermaidNode("issue1", "Test issue 1", "notstarted")
207+
);
208+
graphBuilder.addDependency(
209+
{ repoOwner: "A", repoName: "B", issueNumber: 1 },
210+
{ repoOwner: "A", repoName: "B", issueNumber: 2 }
211+
);
212+
graphBuilder.addIssue(
213+
{ repoOwner: "A", repoName: "B", issueNumber: 2 },
214+
new MermaidNode("issue2", "Test issue 2", "started")
215+
);
216+
217+
const actual = extractNodeIdFromGraph(graphBuilder.getGraph());
218+
expect(actual.vertices).toEqual(["start", "issue1", "issue2", "finish"]);
219+
expect(actual.edges).toEqual([
220+
{ from: "start", to: "issue1" },
221+
{ from: "issue1", to: "issue2" },
222+
{ from: "issue2", to: "finish" },
223+
]);
224+
});
200225
});

0 commit comments

Comments
 (0)