@@ -13,6 +13,7 @@ describe('Unit Tests: Selection Sort Algorithm', () => {
13
13
this . orderedArray = [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ]
14
14
this . reversedArray = [ 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 ]
15
15
this . unorderedArray = [ 0 , 9 , 5 , 2 , 1 , 8 , 7 , 6 , 4 , 3 ]
16
+ this . allEqualArray = [ 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 ]
16
17
} )
17
18
18
19
describe ( 'static less method' , ( ) => {
@@ -58,6 +59,7 @@ describe('Unit Tests: Selection Sort Algorithm', () => {
58
59
describe ( 'static isSorted method' , ( ) => {
59
60
it ( 'should return true if an array is sorted' , ( ) => {
60
61
expect ( Selection . isSorted ( this . orderedArray ) ) . toBe ( true )
62
+ expect ( Selection . isSorted ( this . allEqualArray ) ) . toBe ( true )
61
63
} )
62
64
63
65
it ( 'should return false if the array is not sorted' , ( ) => {
@@ -89,7 +91,7 @@ describe('Unit Tests: Selection Sort Algorithm', () => {
89
91
} )
90
92
} )
91
93
92
- describe ( 'static sort method' , ( ) => {
94
+ describe ( 'static show method' , ( ) => {
93
95
it ( 'should be a function' , ( ) => {
94
96
// I could test the call to StdOut, but I don't want to.
95
97
expect ( Selection . show ) . toBeInstanceOf ( Function )
@@ -121,6 +123,14 @@ describe('Unit Tests: Selection Sort Algorithm', () => {
121
123
expect ( this . reversedArray ) . toEqual ( expectedArray )
122
124
} )
123
125
126
+ it ( 'should sort an array with all the values to be equal' , ( ) => {
127
+ const expectedArray = [ 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 ]
128
+
129
+ Selection . sort ( this . allEqualArray )
130
+
131
+ expect ( this . allEqualArray ) . toEqual ( expectedArray )
132
+ } )
133
+
124
134
it ( 'should sort a small random array' , ( ) => {
125
135
// considering that Selection Sort is slow...
126
136
const n = 1000 // a thousand
0 commit comments