-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
62 lines (47 loc) · 1.36 KB
/
index.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
const {getLongestPalindrome, isPalindromeManual, getLongestPalindromeRecursiveWay} = require('.');
test('isPalindrome should be true', () => {
// Arrange
const string = 'ada';
// Act
const result = isPalindromeManual(string);
// Assert
expect(result).toEqual(true);
})
test('isPalindrome should be false', () => {
// Arrange
const string = 'add';
// Act
const result = isPalindromeManual(string);
// Assert
expect(result).toEqual(false);
})
test('should return the longest palindriome', () => {
// Arrange
const text = 'asdsa4564333339aasdsaa';
// Act
const result = getLongestPalindrome(text);
const resultTwo = getLongestPalindromeRecursiveWay(text);
// Assert
expect(result).toEqual('aasdsaa');
expect(resultTwo).toEqual('aasdsaa');
});
test('should return any palindriome', () => {
// Arrange
const text = 'as39axsdsaa';
// Act
const result = getLongestPalindrome(text);
const resultTwo = getLongestPalindromeRecursiveWay(text);
// Assert
expect(result).toEqual('sds');
expect(resultTwo).toEqual('sds');
});
test('should not return any palindriome', () => {
// Arrange
const text = 'as39ax3ds1a';
// Act
const result = getLongestPalindrome(text);
const resultTwo = getLongestPalindromeRecursiveWay(text);
// Assert
expect(result).toEqual('');
expect(resultTwo).toEqual('');
});