-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2_strings.test.ts
67 lines (50 loc) · 1.73 KB
/
2_strings.test.ts
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, isPalindrome, reverseString } from "../solutions/2_strings.ts";
describe('strings', () => {
let string1: string;
let string2: string;
let string3: string;
let string4: string;
beforeEach(() => {
string1 = '';
string2 = 'baby shark';
string3 = 'b';
string4 = 'racecar';
});
describe('countVowels', () => {
it('should return 0 if string is empty', () => {
expect(countVowels(string1)).toBe(0);
});
it('should return the number of vowels in the string', () => {
expect(countVowels(string2)).toBe(2);
});
});
describe('isPalindrome', () => {
it('should return false if string is empty', () => {
expect(isPalindrome(string1)).toBe(false);
});
it('should return true if string contains only one letter', () => {
expect(isPalindrome(string3)).toBe(true);
});
it('should return true if string is a palindrome', () => {
expect(isPalindrome(string4)).toBe(true);
});
it('should return false if string is not a palindrome', () => {
expect(isPalindrome(string2)).toBe(false);
});
});
describe('reverseString', () => {
it('should return empty string if the given string is empty', () => {
expect(reverseString(string1)).toBe('');
});
it('should return the reverse of the given string', () => {
expect(reverseString(string2)).toEqual('krahs ybab');
});
});
// describe('isAnagram', () => {});
// describe('capitalizeWords', () => {});
// describe('lengthOfLongestSubstring', () => {});
// describe('compressString', () => {});
// describe('longestPalindrome', () => {});
// describe('wildcardMatch', () => {});
// describe('regexParser', () => {});
});