Skip to content

Commit

Permalink
Merge pull request ubiquity-os-marketplace#192 from gentlementlegen/f…
Browse files Browse the repository at this point in the history
…ix/priority

fix: priority default parsing
  • Loading branch information
0x4007 authored Nov 18, 2024
2 parents d9d29aa + 5cab5e6 commit 958cff4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

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 958cff4

Please sign in to comment.