File tree Expand file tree Collapse file tree
unit-testing/chapter-examples/palindrome-example/tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments