@@ -16,7 +16,6 @@ describe('createAnagrams', function() {
16
16
17
17
it ( 'should return an array' , function ( ) {
18
18
var result = createAnagrams ( 'hello' ) ;
19
- console . log ( 'result' , result ) ;
20
19
should . exist ( result ) ;
21
20
result . should . be . an . instanceof ( Array ) ;
22
21
} ) ;
@@ -26,16 +25,16 @@ describe('createAnagrams', function() {
26
25
result . should . be . eql ( [ 'a' ] ) ;
27
26
} ) ;
28
27
29
- it ( 'should return an array of anagrams that contains `lives ` for input `elvis `' , function ( ) {
30
- var result = createAnagrams ( 'elvis ' ) ;
31
- var found = result . indexOf ( 'lives ' ) !== - 1 ;
28
+ it ( 'should return an array of anagrams that contains `nat ` for input `ant `' , function ( ) {
29
+ var result = createAnagrams ( 'ant ' ) ;
30
+ var found = result . indexOf ( 'nat ' ) !== - 1 ;
32
31
found . should . be . true ;
33
32
} ) ;
34
33
35
- it ( 'should return an array of anagrams that contains `badcredit` for input `debitcard` ' , function ( ) {
36
- var result = createAnagrams ( 'debitcard' ) ;
37
- var found = result . indexOf ( 'badcredit' ) !== - 1 ;
38
- found . should . be . true ;
34
+ it ( 'should return a single entry in array if input is same characters ' , function ( ) {
35
+ var expected = [ 'aaa' ] ;
36
+ var result = createAnagrams ( 'aaa' ) ;
37
+ result . length . should . be . equal ( expected . length ) ;
39
38
} ) ;
40
39
41
40
it ( 'should return all anagrams for \'ab\'' , function ( ) {
@@ -49,10 +48,9 @@ describe('createAnagrams', function() {
49
48
}
50
49
} ) ;
51
50
52
- it ( 'should return all anagrams for \'abc\'' , function ( ) {
53
- var expected = [ 'abc' , 'acb' , 'bac' , 'bca' , 'cab' , 'cba' ] ;
54
- var result = createAnagrams ( 'abc' ) ;
55
- result . sort ( ) . should . be . eql ( expected ) ;
51
+ it ( 'should return all anagrams for \'jtb\'' , function ( ) {
52
+ var expected = [ 'jtb' , 'jbt' , 'tjb' , 'tbj' , 'bjt' , 'btj' ] ;
53
+ var result = createAnagrams ( 'jtb' ) ;
56
54
var item , found = false ;
57
55
for ( var i = 0 ; i < expected . length ; i ++ ) {
58
56
item = expected [ i ] ;
@@ -61,28 +59,12 @@ describe('createAnagrams', function() {
61
59
}
62
60
} ) ;
63
61
64
- it ( 'should return all anagrams for \'apps\'' , function ( ) {
65
- var expected = [ 'apps' , 'apsp' , 'aspp' , 'paps' , 'pasp' , 'ppas'
66
- , 'ppsa' , 'psap' , 'pspa' , 'sapp' , 'spap' , 'sppa' ] ;
67
- var result = createAnagrams ( 'apps' ) ;
68
- var item , index , found = false ;
69
- for ( var i = 0 ; i < expected . length ; i ++ ) {
70
- item = expected [ i ] ;
71
- found = result . indexOf ( item ) !== - 1 ;
72
- found . should . be . true ;
73
- }
74
- } ) ;
75
-
76
- it ( 'should return all __unique__ anagrams for \'apps\'' , function ( ) {
62
+ it ( 'should return only unique anagrams for \'apps\'' , function ( ) {
77
63
var expected = [ 'apps' , 'apsp' , 'aspp' , 'paps' , 'pasp' , 'ppas' , 'ppsa'
78
64
, 'psap' , 'pspa' , 'sapp' , 'spap' , 'sppa' ] ;
79
65
var match = true ;
80
66
var result = createAnagrams ( 'apps' ) ;
81
67
result . length . should . be . equal ( expected . length ) ;
82
68
} ) ;
83
69
84
- it ( 'should not use underscore\'s `uniq`' , function ( ) {
85
- var usesUniq = createAnagrams . toString ( ) . match ( / \s * _ \. u n i q / ) === null ;
86
- usesUniq . should . be . true ;
87
- } )
88
70
} ) ;
0 commit comments