Skip to content

Commit

Permalink
fix: add priority parsing tests
Browse files Browse the repository at this point in the history
Add tests for default and specific priority labels. Fix default 1.
  • Loading branch information
gentlementlegen committed Nov 18, 2024
1 parent d9d29aa commit dbf0ab3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/parser/formatting-evaluator-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ export class FormattingEvaluatorModule extends BaseModule {
}

_parsePriorityLabel(labels: GitHubIssue["labels"] | undefined): number {
let taskPriorityEstimate = 0;
// Has to default to 1 in case there is no priority label
let taskPriorityEstimate = 1;
if (!labels) return 1;
for (const label of labels) {
let priorityLabel = "";
Expand Down
31 changes: 31 additions & 0 deletions tests/priority.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { ContextPlugin } from "../src/types/plugin-input";
import { FormattingEvaluatorModule } from "../src/parser/formatting-evaluator-module";
import { GitHubIssue } from "../src/github-types";
import { describe, expect, it, jest } from "@jest/globals";

describe("FormattingEvaluatorModule", () => {
const context = {
config: {
incentives: {
formattingEvaluator: null,
},
},
logger: {
error: jest.fn(),
},
} as unknown as ContextPlugin;

const module = new FormattingEvaluatorModule(context);

it("should default to priority 1 when no priority label is present", () => {
const labels: GitHubIssue["labels"] = [];
const priority = module["_parsePriorityLabel"](labels);
expect(priority).toBe(1);
});

it('should return priority 3 when "Priority: 3" label is present', () => {
const labels = ["Priority: 3"];
const priority = module["_parsePriorityLabel"](labels);
expect(priority).toBe(3);
});
});

0 comments on commit dbf0ab3

Please sign in to comment.