-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEx1-test.js
More file actions
70 lines (59 loc) · 2.09 KB
/
Ex1-test.js
File metadata and controls
70 lines (59 loc) · 2.09 KB
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
let expect = require("chai").expect;
//Arrange
function isPalindrome(str) {
let strReversed = "";
for (var i = str.length - 1; i >= 0; i--) {
strReversed += str[i];
}
if (strReversed == str) {
return "palindrome";
} else {
return "not a palindrome";
}
}
//Test
//Palindromes
describe("The following test-cases should reslove to palindromes:", function() {
it('should return "palindrome"', function() {
expect(isPalindrome("ava")).to.equal("palindrome");
});
it('should return "palindrome"', function() {
expect(isPalindrome("a")).to.equal("palindrome");
});
it('should return "palindrome"', function() {
expect(isPalindrome("aa")).to.equal("palindrome");
});
it('should return "palindrome"', function() {
expect(isPalindrome("afa")).to.equal("palindrome");
});
it('should return "palindrome"', function() {
expect(isPalindrome("acca")).to.equal("palindrome");
});
it('should return "palindrome"', function() {
expect(isPalindrome("acdca")).to.equal("palindrome");
});
});
//Non palindromes
describe("The following test-cases should not resolve to a palindrome:", function() {
it('should return "not a palindrome"', function() {
expect(isPalindrome("sad")).to.equal("not a palindrome");
});
it('should return "not a palindrome"', function() {
expect(isPalindrome("as")).to.equal("not a palindrome");
});
it('should return "not a palindrome"', function() {
expect(isPalindrome("aaas")).to.equal("not a palindrome");
});
it('should return "not a palindrome"', function() {
expect(isPalindrome("aabb")).to.equal("not a palindrome");
});
it('should return "not a palindrome"', function() {
expect(isPalindrome("add")).to.equal("not a palindrome");
});
it('should return "not a palindrome"', function() {
expect(isPalindrome("sdk")).to.equal("not a palindrome");
});
it('should return "not a palindrome"', function() {
expect(isPalindrome("aacc")).to.equal("not a palindrome");
});
})