Files
Bubberstation/tools/pull_request_hooks/changelogParser.test.js
Roxy bd76bc2e9b Make Autochangelog case-insensitive for tags (#91678)
## About The Pull Request

Changes `changelogParser.js` so looking up the changelog entry type is
case-insensitive e.g. `Fix: blahblah` is recognized. Also added a new
test in `changelogParser.test.js` to test the functionality

## Why It's Good For The Game

I fucked this up once and I saw someone else fuck it up recently (in my
case I backspaced the changelog cause I didn't think it needed one, then
later decided it did but I capitalized the tag name and it caused there
to be no changelog entry once merged) and it's a dead simple thing to
account for

## Changelog
🆑
code: Autochangelog no longer cares if your changelog entry tag has
capital letters in it
/🆑
2025-06-21 22:21:56 -04:00

86 lines
2.0 KiB
JavaScript

import { strict as assert } from "node:assert";
import { parseChangelog } from "./changelogParser.js";
// Basic test
const basicChangelog = parseChangelog(`
My cool PR!
:cl: DenverCoder9
add: Adds new stuff
/:cl:
`);
assert.equal(basicChangelog.author, "DenverCoder9");
assert.equal(basicChangelog.changes.length, 1);
assert.equal(basicChangelog.changes[0].type.changelogKey, "rscadd");
assert.equal(basicChangelog.changes[0].description, "Adds new stuff");
// Case-insensitivity test
const mixedCaseChangelog = parseChangelog(`
My cool PR!
:cl: DenverCoder9
Add: Adds new stuff
/:cl:
`);
assert.equal(mixedCaseChangelog.author, "DenverCoder9");
assert.equal(mixedCaseChangelog.changes.length, 1);
assert.equal(mixedCaseChangelog.changes[0].type.changelogKey, "rscadd");
assert.equal(mixedCaseChangelog.changes[0].description, "Adds new stuff");
// Multi-line test
const multiLineChangelog = parseChangelog(`
My cool PR!
:cl:
add: Adds new stuff
to the game
/:cl:
`);
assert.equal(multiLineChangelog.author, undefined);
assert.equal(multiLineChangelog.changes.length, 1);
assert.equal(multiLineChangelog.changes[0].type.changelogKey, "rscadd");
assert.equal(
multiLineChangelog.changes[0].description,
"Adds new stuff\nto the game",
);
// Placeholders
const placeholderChangelog = parseChangelog(`
My cool PR!
:cl:
add: Added new mechanics or gameplay changes
/:cl:
`);
assert.equal(placeholderChangelog.changes.length, 0);
// No changelog
const noChangelog = parseChangelog(`
My cool PR!
`);
assert.equal(noChangelog, undefined);
// No /:cl:
const noCloseChangelog = parseChangelog(`
My cool PR!
:cl:
add: Adds new stuff
`);
assert.equal(noCloseChangelog.changes.length, 1);
assert.equal(noCloseChangelog.changes[0].type.changelogKey, "rscadd");
assert.equal(noCloseChangelog.changes[0].description, "Adds new stuff");
// :cl: with arbitrary text
const arbitraryTextChangelog = parseChangelog(`
My cool PR!
:cl:
Adds new stuff
/:cl:
`);
assert.equal(arbitraryTextChangelog.changes.length, 0);