1
- import { checkWordOccurrence } from './CheckWordOccurrence' ;
1
+ import { checkWordOccurrence } from './CheckWordOccurrence'
2
2
describe ( 'checkWordOccurrence' , ( ) => {
3
3
it ( 'expects throw on insert wrong string' , ( ) => {
4
- const value = 123 ;
5
- expect ( ( ) => checkWordOccurrence ( value ) ) . toThrow ( ) ;
6
- } ) ;
4
+ const value = 123
5
+ expect ( ( ) => checkWordOccurrence ( value ) ) . toThrow ( )
6
+ } )
7
7
it ( 'expect throw on insert wrong param for case sensitive' , ( ) => {
8
- const value = 'hello' ;
9
- expect ( ( ) => checkWordOccurrence ( value , value ) ) . toThrow ( ) ;
10
- } ) ;
8
+ const value = 'hello'
9
+ expect ( ( ) => checkWordOccurrence ( value , value ) ) . toThrow ( )
10
+ } )
11
11
it ( 'check occurrence with case sensitive' , ( ) => {
12
- const stringToTest = " A Mad World" ;
13
- const charsOccurrences = checkWordOccurrence ( stringToTest , true ) ;
14
- const expectResult = { A : 1 , M : 1 , a : 1 , d : 2 , W : 1 , l : 1 , o : 1 , r : 1 } ;
15
- const occurrencesObjectKeys = Object . keys ( charsOccurrences ) ;
16
- const expectObjectKeys = Object . keys ( expectResult ) ;
17
- expect ( occurrencesObjectKeys . length ) . toBe ( expectObjectKeys . length ) ;
12
+ const stringToTest = ' A Mad World'
13
+ const charsOccurrences = checkWordOccurrence ( stringToTest , true )
14
+ const expectResult = { A : 1 , M : 1 , a : 1 , d : 2 , W : 1 , l : 1 , o : 1 , r : 1 }
15
+ const occurrencesObjectKeys = Object . keys ( charsOccurrences )
16
+ const expectObjectKeys = Object . keys ( expectResult )
17
+ expect ( occurrencesObjectKeys . length ) . toBe ( expectObjectKeys . length )
18
18
expectObjectKeys . forEach ( key => {
19
- expect ( expectResult [ key ] ) . toBe ( charsOccurrences [ key ] ) ;
20
- } ) ;
21
- } ) ;
19
+ expect ( expectResult [ key ] ) . toBe ( charsOccurrences [ key ] )
20
+ } )
21
+ } )
22
22
it ( 'check occurrence with case insensitive' , ( ) => {
23
- const stringToTest = " A Mad World" ;
24
- const charsOccurrences = checkWordOccurrence ( stringToTest , false ) ;
25
- const expectResult = { A : 2 , D : 2 , L : 1 , M : 1 , O : 1 , R : 1 , W : 1 } ;
26
- const occurrencesObjectKeys = Object . keys ( charsOccurrences ) ;
27
- const expectObjectKeys = Object . keys ( expectResult ) ;
28
- expect ( occurrencesObjectKeys . length ) . toBe ( expectObjectKeys . length ) ;
23
+ const stringToTest = ' A Mad World'
24
+ const charsOccurrences = checkWordOccurrence ( stringToTest , false )
25
+ const expectResult = { A : 2 , D : 2 , L : 1 , M : 1 , O : 1 , R : 1 , W : 1 }
26
+ const occurrencesObjectKeys = Object . keys ( charsOccurrences )
27
+ const expectObjectKeys = Object . keys ( expectResult )
28
+ expect ( occurrencesObjectKeys . length ) . toBe ( expectObjectKeys . length )
29
29
expectObjectKeys . forEach ( key => {
30
- expect ( expectResult [ key ] ) . toBe ( charsOccurrences [ key ] ) ;
31
- } ) ;
32
-
33
- } ) ;
34
- } ) ;
30
+ expect ( expectResult [ key ] ) . toBe ( charsOccurrences [ key ] )
31
+ } )
32
+ } )
33
+ } )
0 commit comments