Skip to content

Commit

Permalink
Merge pull request #1133 from guardian/wordcount-fix
Browse files Browse the repository at this point in the history
Fix bug in word limit
  • Loading branch information
davidfurey authored Aug 8, 2024
2 parents 9bf3b8a + bb93255 commit 0901331
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ export const getWords = (text: string): string[] => {
};

export const isTooLong = (value: string, maxWordLength: number): boolean => {
const wordLength = getWords(value).reduce((length, word) => {
length += word.length;
return length;
}, 0);
const wordLength = getWords(value).length;
return (
wordLength > maxWordLength
);
Expand Down
4 changes: 2 additions & 2 deletions public/video-ui/src/test/richTextInput.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ describe("getWords", () => {
});

describe("isTooLong", () => {
it('Should return false for phrases less than the character and word limit', () => {
it('Should return false for phrases less than the word limit', () => {
const tooLongString = "So it goes";
const maxWords = 100;
const maxWords = 3;

const isTooLongResult = isTooLong(tooLongString, maxWords);

Expand Down

0 comments on commit 0901331

Please sign in to comment.