mirror of
https://github.com/Citadel-Station-13/Citadel-Station-13-RP.git
synced 2026-08-25 23:56:38 +01:00
78 lines
1.7 KiB
JavaScript
78 lines
1.7 KiB
JavaScript
import { strict as assert } from "node:assert";
|
|
import { get_updated_label_set } from "./autoLabel.js";
|
|
|
|
const empty_pr = {
|
|
action: "opened",
|
|
pull_request: {
|
|
body: "This PR will have no labels",
|
|
title: "Pr with no labels",
|
|
mergeable: true,
|
|
},
|
|
};
|
|
const empty_label_set = await get_updated_label_set({
|
|
github: null,
|
|
context: { payload: empty_pr },
|
|
});
|
|
assert.equal(empty_label_set.length, 0, "No labels should be added");
|
|
|
|
const cl = `
|
|
My Awesome PR
|
|
|
|
:cl: Awesome Dude
|
|
add: Adds Awesome Stuff
|
|
refactor: refactored some code
|
|
:/cl:
|
|
`;
|
|
const cl_pr = {
|
|
action: "opened",
|
|
pull_request: {
|
|
body: cl,
|
|
title: "Awesome PR",
|
|
mergeable: false,
|
|
},
|
|
};
|
|
const cl_label_set = await get_updated_label_set({
|
|
github: null,
|
|
context: { payload: cl_pr },
|
|
});
|
|
assert.ok(
|
|
cl_label_set.includes("Merge Conflict"),
|
|
"Merge Conflict label should be added",
|
|
);
|
|
assert.ok(cl_label_set.includes("Feature"), "Feature label should be added");
|
|
assert.ok(
|
|
!cl_label_set.includes("Refactor"),
|
|
"Refactor label should not be added",
|
|
);
|
|
|
|
const title_pr = {
|
|
action: "opened",
|
|
pull_request: {
|
|
title: "Logging is important",
|
|
mergeable: true,
|
|
},
|
|
};
|
|
const title_label_set = await get_updated_label_set({
|
|
github: null,
|
|
context: { payload: title_pr },
|
|
});
|
|
assert.ok(title_label_set.includes("Logging"), "Logging label should be added");
|
|
|
|
const size_label_pr = {
|
|
action: "opened",
|
|
pull_request: {
|
|
body: "DONT REMOVE THE SIZE LABEL AAAAA",
|
|
title: "Pr with size labels",
|
|
mergeable: true,
|
|
},
|
|
};
|
|
const size_label_set = await get_updated_label_set({
|
|
github: null,
|
|
context: { payload: size_label_pr },
|
|
labels: ["size/XXL"],
|
|
});
|
|
assert.ok(
|
|
size_label_set.includes("size/XXL"),
|
|
"Size label shouldnt get deleted",
|
|
);
|