forked from TheAlgorithms/JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCountLetters.test.js
33 lines (27 loc) · 1012 Bytes
/
CountLetters.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { countLetters } from '../CountLetters'
describe('CountLetters', () => {
it('expect throws on use wrong param', () => {
expect(() => countLetters(0)).toThrow()
})
it('expect throws when using a number in the string', () => {
expect(() => countLetters('h3llo')).toThrow()
})
it('expect throws when using a special characters in the string', () => {
expect(() => countLetters('hello!')).toThrow()
})
it('count the letters in a string. Allows lower case', () => {
const value = 'hello'
const count = countLetters(value)
expect(count).toEqual({ h: 1, e: 1, l: 2, o: 1 })
})
it('count the letters in a string. Allows upper case', () => {
const value = 'HELLO'
const count = countLetters(value)
expect(count).toEqual({ h: 1, e: 1, l: 2, o: 1 })
})
it('count the letters in a string. Allows upper and lower case', () => {
const value = 'HelLo'
const count = countLetters(value)
expect(count).toEqual({ h: 1, e: 1, l: 2, o: 1 })
})
})