fix ident file

This commit is contained in:
Carlos Carvalho
2020-10-05 23:52:21 -03:00
parent dd40c139d5
commit fbd3442cf0
2 changed files with 44 additions and 44 deletions

View File

@ -15,7 +15,7 @@ const checkWordOccurrence = (str, isCaseSensitive = false) => {
if (str.length > 0) { if (str.length > 0) {
for (let i = 0; i < str.length; i++) { for (let i = 0; i < str.length; i++) {
const word = isCaseSensitive ? str[i] : str[i].toUpperCase() const word = isCaseSensitive ? str[i] : str[i].toUpperCase()
if(/\s/.test(word)) continue; if (/\s/.test(word)) continue;
result[word] = (!result[word]) ? 1 : result[word] + 1 result[word] = (!result[word]) ? 1 : result[word] + 1
} }

View File

@ -1,4 +1,4 @@
import {checkWordOccurrence} from './CheckWordOccurrence'; import { checkWordOccurrence } from './CheckWordOccurrence';
describe('checkWordOccurrence', () => { describe('checkWordOccurrence', () => {
it('expects throw on insert wrong string', () => { it('expects throw on insert wrong string', () => {
const value = 123; const value = 123;
@ -11,7 +11,7 @@ describe('checkWordOccurrence', () => {
it('check occurrence with case sensitive', () => { it('check occurrence with case sensitive', () => {
const stringToTest = "A Mad World"; const stringToTest = "A Mad World";
const charsOccurrences = checkWordOccurrence(stringToTest, true); const charsOccurrences = checkWordOccurrence(stringToTest, true);
const expectResult = {A: 1, M: 1, a: 1, d: 2, W: 1, l: 1, o: 1, r: 1}; const expectResult = { A: 1, M: 1, a: 1, d: 2, W: 1, l: 1, o: 1, r: 1 };
const occurrencesObjectKeys = Object.keys(charsOccurrences); const occurrencesObjectKeys = Object.keys(charsOccurrences);
const expectObjectKeys = Object.keys(expectResult); const expectObjectKeys = Object.keys(expectResult);
expect(occurrencesObjectKeys.length).toBe(expectObjectKeys.length); expect(occurrencesObjectKeys.length).toBe(expectObjectKeys.length);
@ -22,7 +22,7 @@ describe('checkWordOccurrence', () => {
it('check occurrence with case insensitive', () => { it('check occurrence with case insensitive', () => {
const stringToTest = "A Mad World"; const stringToTest = "A Mad World";
const charsOccurrences = checkWordOccurrence(stringToTest, false); const charsOccurrences = checkWordOccurrence(stringToTest, false);
const expectResult = {A: 2, D: 2, L: 1, M: 1, O: 1, R: 1, W: 1}; const expectResult = { A: 2, D: 2, L: 1, M: 1, O: 1, R: 1, W: 1 };
const occurrencesObjectKeys = Object.keys(charsOccurrences); const occurrencesObjectKeys = Object.keys(charsOccurrences);
const expectObjectKeys = Object.keys(expectResult); const expectObjectKeys = Object.keys(expectResult);
expect(occurrencesObjectKeys.length).toBe(expectObjectKeys.length); expect(occurrencesObjectKeys.length).toBe(expectObjectKeys.length);