forked from TheAlgorithms/JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCountVowels.test.js
67 lines (56 loc) · 1.88 KB
/
CountVowels.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { countVowels } from '../CountVowels'
describe('CountVowels', () => {
it('expect throws on use wrong param', () => {
expect(() => countVowels(0)).toThrow()
})
it('count the vowels in a string', () => {
const value = 'Mad World'
const count = countVowels(value)
expect(count).toBe(2)
})
it('should return 0 when input is a string with no vowels', () => {
const value = 'bcdfgh'
const count = countVowels(value)
expect(count).toBe(0)
})
it('should return 1 when input is a string of length 1 that is a vowel', () => {
const value = 'a'
const count = countVowels(value)
expect(count).toBe(1)
})
it('should return the correct result when input is in all uppercase letters', () => {
const value = 'ABCDE'
const count = countVowels(value)
expect(count).toBe(2)
})
it('should return the correct result when input is in all lowercase letters', () => {
const value = 'abcdefghi'
const count = countVowels(value)
expect(count).toBe(3)
})
it('should return the correct result when input string contains spaces', () => {
const value = 'abc def ghi'
const count = countVowels(value)
expect(count).toBe(3)
})
it('should return the correct result when input contains number characters', () => {
const value = 'a1b2c3'
const count = countVowels(value)
expect(count).toBe(1)
})
it('should return the correct result when input contains punctuation characters', () => {
const value = 'a!b.ce)'
const count = countVowels(value)
expect(count).toBe(2)
})
it('should return 0 when the input is an empty string', () => {
const value = ''
const count = countVowels(value)
expect(count).toBe(0)
})
it('should count multiple occurrences of the same vowel in the input', () => {
const value = 'aaaaa'
const count = countVowels(value)
expect(count).toBe(5)
})
})