Skip to content

Commit

Permalink
fix contractions in sentences (#1151)
Browse files Browse the repository at this point in the history
  • Loading branch information
vazish authored Dec 7, 2023
1 parent 60ddaf9 commit bf32f6b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
26 changes: 13 additions & 13 deletions src/_shared/utils/applyApTitleCase.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,26 +82,14 @@ describe('applyApTitleCase', () => {
});
});

it('words after curly apostrophes should be uppercase', () => {
it('words after double apostrophes should be uppercase', () => {
const sentencesWithApostrophe = [
{
result:
'“Integrated thriving” can fix unhelpful buzz words like “girlboss” and “snail girl”',
expected:
'“Integrated Thriving” Can Fix Unhelpful Buzz Words Like “Girlboss” and “Snail Girl”',
},
{
result:
'‘Integrated thriving’ can fix unhelpful buzz words like ‘girlboss’ and ‘snail girl’',
expected:
'‘Integrated Thriving’ Can Fix Unhelpful Buzz Words Like ‘Girlboss’ and ‘Snail Girl’',
},
{
result:
"'Integrated thriving' can fix unhelpful buzz words like 'girlboss' and 'snail girl'",
expected:
"'Integrated Thriving' Can Fix Unhelpful Buzz Words Like 'Girlboss' and 'Snail Girl'",
},
{
result:
'"Integrated thriving" can fix unhelpful buzz words like "girlboss" and "snail girl"',
Expand All @@ -113,4 +101,16 @@ describe('applyApTitleCase', () => {
expect(applyApTitleCase(swa.result)).toEqual(swa.expected);
});
});

it('contractions should be properly uppercase', () => {
const sentencesWithContractions = [
{
result: "Here's what you haven't noticed",
expected: "Here's What You Haven't Noticed",
},
];
sentencesWithContractions.forEach((swc) => {
expect(applyApTitleCase(swc.result)).toEqual(swc.expected);
});
});
});
2 changes: 1 addition & 1 deletion src/_shared/utils/applyApTitleCase.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const STOP_WORDS =
'a an and at but by for in nor of on or so the to up yet';

export const SEPARATORS = /(\s+|[-,:;!?()'"])/;
export const SEPARATORS = /(\s+|[-,:;!?()"])/;

export const stop = STOP_WORDS.split(' ');

Expand Down

0 comments on commit bf32f6b

Please sign in to comment.