Skip to content

Commit a8bc001

Browse files
committed
add tests for palindrome
1 parent 5cba577 commit a8bc001

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const isPalindrome = require("../palindrome.js");
2+
3+
describe("testing isPalindrome", function () {
4+
test("should return true for a single letter", function () {
5+
expect(isPalindrome("a")).toBe(true);
6+
});
7+
8+
test("should return true for a single letter repeated", function () {
9+
expect(isPalindrome("aaa")).toBe(true);
10+
});
11+
12+
test("should return true for a simple palindrome", function () {
13+
expect(isPalindrome("aba")).toBe(true);
14+
});
15+
16+
test("should return true for a longer palindrome", function () {
17+
expect(isPalindrome("racecar")).toBe(true);
18+
});
19+
test("should return false for a longer non-palindrome", function () {
20+
expect(isPalindrome("launchcode")).toBe(false);
21+
});
22+
23+
test("should return false for a simple non-palindrome", function () {
24+
expect(isPalindrome("ab")).toBe(false);
25+
});
26+
27+
test("should be case-sensitive", function () {
28+
expect(isPalindrome("abA")).toBe(false);
29+
});
30+
31+
test("should consider whitespace", function () {
32+
expect(isPalindrome("so many dynamos")).toBe(false);
33+
});
34+
35+
test("should consider the empty string a palindrome", function () {
36+
expect(isPalindrome("")).toBe(true);
37+
});
38+
});

0 commit comments

Comments
 (0)