diff --git a/__tests__/TitleCaser.test.js b/__tests__/TitleCaser.test.js index eda0a43..03cd146 100644 --- a/__tests__/TitleCaser.test.js +++ b/__tests__/TitleCaser.test.js @@ -11,6 +11,15 @@ const createTest = (description, input, expected) => { }); }; + +describe(` + Testing Combined Words that End with Symbol`, () => { + createTest('Capitalizes country code "US" correctly in a geopolitical context', + 'Championing Self-Acceptance: Landmark Initiative', + 'Championing Self-Acceptance: Landmark Initiative'); +}); + + describe(` Testing Acronym/Pronoun of Alpha2/3 Country Codes`, () => { createTest('Capitalizes country code "US" correctly in a geopolitical context', diff --git a/src/TitleCaser.js b/src/TitleCaser.js index 1ef2333..9111c08 100644 --- a/src/TitleCaser.js +++ b/src/TitleCaser.js @@ -111,10 +111,8 @@ export class TitleCaser { const isReplaced = !replacedParts.every((part, index) => part === parts[index]); // Reassemble the word with the hyphen, reattach trailing punctuation, and return - return ( - (isReplaced ? replacedParts.join("-") : TitleCaserUtils.correctTermHyphenated(word, style)) + - trailingPunctuation - ); + const processedWord = isReplaced ? replacedParts.join("-") : TitleCaserUtils.correctTermHyphenated(word, style); + return processedWord.endsWith(trailingPunctuation) ? processedWord : processedWord + trailingPunctuation; case TitleCaserUtils.hasSuffix(word, style): // If the word has a suffix, return the correct casing. return TitleCaserUtils.correctSuffix(word, correctTitleCasingList);