Skip to content

Commit

Permalink
Merge pull request #10 from maxim-lobanov/malob/fix-reference-bug
Browse files Browse the repository at this point in the history
Fix bug with referencing unknown issue
  • Loading branch information
maxim-lobanov committed Feb 22, 2023
2 parents c792738 + 8307d5b commit 53ddbb4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ class GraphBuilder {
graphNode = { value: issue, predecessors: [], successors: [] };
this.nodes.set(nodeKey, graphNode);
}
else if (issue) {
graphNode.value = issue;
}
return graphNode;
}
addIssue(issueReference, issue) {
Expand Down
2 changes: 2 additions & 0 deletions src/graph-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export class GraphBuilder {
if (!graphNode) {
graphNode = { value: issue, predecessors: [], successors: [] };
this.nodes.set(nodeKey, graphNode);
} else if (issue) {
graphNode.value = issue;
}

return graphNode;
Expand Down
25 changes: 25 additions & 0 deletions tests/graph-builder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,29 @@ describe("GraphBuilder", () => {
{ from: "issue3", to: "finish" },
]);
});

it("Add dependency before adding node", () => {
const graphBuilder = new GraphBuilder(true);

graphBuilder.addIssue(
{ repoOwner: "A", repoName: "B", issueNumber: 1 },
new MermaidNode("issue1", "Test issue 1", "notstarted")
);
graphBuilder.addDependency(
{ repoOwner: "A", repoName: "B", issueNumber: 1 },
{ repoOwner: "A", repoName: "B", issueNumber: 2 }
);
graphBuilder.addIssue(
{ repoOwner: "A", repoName: "B", issueNumber: 2 },
new MermaidNode("issue2", "Test issue 2", "started")
);

const actual = extractNodeIdFromGraph(graphBuilder.getGraph());
expect(actual.vertices).toEqual(["start", "issue1", "issue2", "finish"]);
expect(actual.edges).toEqual([
{ from: "start", to: "issue1" },
{ from: "issue1", to: "issue2" },
{ from: "issue2", to: "finish" },
]);
});
});

0 comments on commit 53ddbb4

Please sign in to comment.