Skip to content

Commit 3c90d5d

Browse files
chore: merge "Tests check vowels (#691)"
* add tests to CheckVowels to cover additional inputs and edge cases * make line spacing consistent with other test files
1 parent 340f8e5 commit 3c90d5d

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

String/CheckVowels.test.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,64 @@ describe('Test the checkVowels function', () => {
44
it('expect throws on use wrong param', () => {
55
expect(() => checkVowels(0)).toThrow()
66
})
7+
78
it('count the vowels in a string', () => {
89
const value = 'Mad World'
910
const countVowels = checkVowels(value)
1011
expect(countVowels).toBe(2)
1112
})
13+
14+
it('should return 0 when input is a string with no vowels', () => {
15+
const value = 'bcdfgh'
16+
const countVowels = checkVowels(value)
17+
expect(countVowels).toBe(0)
18+
})
19+
20+
it('should return 1 when input is a string of length 1 that is a vowel', () => {
21+
const value = 'a'
22+
const countVowels = checkVowels(value)
23+
expect(countVowels).toBe(1)
24+
})
25+
26+
it('should return the correct result when input is in all uppercase letters', () => {
27+
const value = 'ABCDE'
28+
const countVowels = checkVowels(value)
29+
expect(countVowels).toBe(2)
30+
})
31+
32+
it('should return the correct result when input is in all lowercase letters', () => {
33+
const value = 'abcdefghi'
34+
const countVowels = checkVowels(value)
35+
expect(countVowels).toBe(3)
36+
})
37+
38+
it('should return the correct result when input string contains spaces', () => {
39+
const value = 'abc def ghi'
40+
const countVowels = checkVowels(value)
41+
expect(countVowels).toBe(3)
42+
})
43+
44+
it('should return the correct result when input contains number characters', () => {
45+
const value = 'a1b2c3'
46+
const countVowels = checkVowels(value)
47+
expect(countVowels).toBe(1)
48+
})
49+
50+
it('should return the correct result when input contains punctuation characters', () => {
51+
const value = 'a!b.ce)'
52+
const countVowels = checkVowels(value)
53+
expect(countVowels).toBe(2)
54+
})
55+
56+
it('should return 0 when the input is an empty string', () => {
57+
const value = ''
58+
const countVowels = checkVowels(value)
59+
expect(countVowels).toBe(0)
60+
})
61+
62+
it('should count multiple occurances of the same vowel in the input', () => {
63+
const value = 'aaaaa'
64+
const countVowels = checkVowels(value)
65+
expect(countVowels).toBe(5)
66+
})
1267
})

0 commit comments

Comments
 (0)