Skip to content

Commit

Permalink
fix: added support for uppercase in multiplier regex (#503)
Browse files Browse the repository at this point in the history
* fix: added support for uppercase in multiplier regex

* fix: added the 2nd part of the multiplier regex back

* test: added test case for uppercase multiplier
  • Loading branch information
anthonygauthier authored Mar 8, 2024
1 parent f3f83f8 commit 5394a7c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion service/recognition.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const tagRegex = /#(\S+)/g;
const generalEmojiRegex = /:([a-z-_']+):/g;
const gratitudeEmojiRegex = new RegExp(config.recognizeEmoji, "g");
const multiplierRegex = new RegExp(
`${config.recognizeEmoji}\\s*x([0-9]+)|x([0-9]+)\\s${config.recognizeEmoji}`,
`${config.recognizeEmoji}\\s*[Xx]([0-9]+)|[Xx]([0-9]+)\\s${config.recognizeEmoji}`,
);

// TODO Can we add a 'count' field to the recognition?
Expand Down
14 changes: 14 additions & 0 deletions test/service/recognition.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,20 @@ describe("service/recognition", () => {
const result = recognition.gratitudeCountIn(text);
expect(result).to.equal(5);
});

it("should count uppercase multiplier", async () => {
const text =
"uppercase multiplier X5 :fistbump: <@TestUser> Test Message";
const result = recognition.gratitudeCountIn(text);
expect(result).to.equal(5);
});

it("shouldn't use an uppercase multiplier that's not 'X'", async () => {
const text =
"uppercase fake multiplier Y5 :fistbump: <@TestUser> Test Message";
const result = recognition.gratitudeCountIn(text);
expect(result).to.equal(1);
});
});

describe("gratitudeTagsIn", () => {
Expand Down

0 comments on commit 5394a7c

Please sign in to comment.