@@ -20,7 +20,7 @@ describe('BetterArray', function() {
20
20
expect ( ba ( [ 2 , 3 , 4 ] ) . at ( 1 ) ) . toEqual ( 3 ) ;
21
21
} ) ;
22
22
23
- it ( "returns values at that indexes for multiple argument " , function ( ) {
23
+ it ( "returns values at that indexes for multiple arguments " , function ( ) {
24
24
expect ( ba ( [ 2 , 3 , 4 ] ) . at ( 0 , 2 ) ) . toEqual ( [ 2 , 4 ] ) ;
25
25
} ) ;
26
26
} ) ;
@@ -31,6 +31,11 @@ describe('BetterArray', function() {
31
31
ba ( array ) . $clear ( ) ;
32
32
expect ( array ) . toEqual ( [ ] ) ;
33
33
} ) ;
34
+
35
+ it ( "returns the empty array" , function ( ) {
36
+ var array = [ 2 , 3 , 4 ] ;
37
+ expect ( ba ( array ) . $clear ( ) ) . toEqual ( [ ] ) ;
38
+ } ) ;
34
39
} ) ;
35
40
36
41
describe ( '.clone' , function ( ) {
@@ -52,7 +57,7 @@ describe('BetterArray', function() {
52
57
} ) ;
53
58
54
59
describe ( '.contains' , function ( ) {
55
- it ( "returns array with no double entries " , function ( ) {
60
+ it ( "checks if an element is included in the array " , function ( ) {
56
61
expect ( ba ( [ 2 , 3 , 4 ] ) . contains ( 4 ) ) . toEqual ( true ) ;
57
62
expect ( ba ( [ 2 , 3 , 4 ] ) . contains ( 5 ) ) . toEqual ( false ) ;
58
63
} ) ;
@@ -155,6 +160,11 @@ describe('BetterArray', function() {
155
160
ba ( array ) . $insert ( 1 , 2.5 ) ;
156
161
expect ( array ) . toEqual ( [ 2 , 2.5 , 3 , 4 ] ) ;
157
162
} ) ;
163
+
164
+ it ( "returns the updated array" , function ( ) {
165
+ var array = [ 2 , 3 , 4 ] ;
166
+ expect ( ba ( array ) . $insert ( 1 , 2.5 ) ) . toEqual ( [ 2 , 2.5 , 3 , 4 ] ) ;
167
+ } ) ;
158
168
} ) ;
159
169
160
170
describe ( '.isEmpty' , function ( ) {
@@ -193,13 +203,13 @@ describe('BetterArray', function() {
193
203
194
204
describe ( '.minus' , function ( ) {
195
205
it ( "takes values from array without the ones from the other array" , function ( ) {
196
- expect ( ba ( [ 2 , 3 , 4 ] ) . minus ( [ 3 , 4 , 5 ] ) ) . toEqual ( [ 2 ] ) ;
206
+ expect ( ba ( [ 2 , 3 , 4 ] ) . minus ( [ 3 , 4 , 5 ] ) ) . toEqual ( [ 2 ] ) ;
197
207
} ) ;
198
208
} ) ;
199
209
200
210
describe ( '.or' , function ( ) {
201
211
it ( "returns a uniqe array out of all elements of both arrays" , function ( ) {
202
- expect ( ba ( [ 2 , 3 , 4 ] ) . or ( [ 3 , 4 , 4 , 5 ] ) ) . toEqual ( [ 2 , 3 , 4 , 5 ] ) ;
212
+ expect ( ba ( [ 2 , 3 , 4 ] ) . or ( [ 3 , 4 , 4 , 5 ] ) ) . toEqual ( [ 2 , 3 , 4 , 5 ] ) ;
203
213
} ) ;
204
214
} ) ;
205
215
@@ -285,17 +295,19 @@ describe('BetterArray', function() {
285
295
} ) ;
286
296
287
297
it ( "rotates by 1 without argument" , function ( ) {
288
- expect ( ba ( [ 2 , 3 , 4 , 5 , 6 ] ) . rotate ( 1 ) ) . toEqual ( [ 3 , 4 , 5 , 6 , 2 ] ) ;
298
+ expect ( ba ( [ 2 , 3 , 4 , 5 , 6 ] ) . rotate ( ) ) . toEqual ( [ 3 , 4 , 5 , 6 , 2 ] ) ;
289
299
} ) ;
290
300
} ) ;
291
301
292
302
describe ( '.$set' , function ( ) {
293
303
it ( "sets the element at this index and returns array" , function ( ) {
294
- expect ( ba ( [ 2 , 3 , 4 ] ) . $set ( 1 , "three" ) ) . toEqual ( [ 2 , "three" , 4 ] ) ;
304
+ var array = [ 2 , 3 , 4 ] ;
305
+ ba ( array ) . $set ( 1 , "three" )
306
+ expect ( array ) . toEqual ( [ 2 , "three" , 4 ] ) ;
295
307
} ) ;
296
308
297
- it ( "returns values at that indexes for multiple argument " , function ( ) {
298
- expect ( ba ( [ 2 , 3 , 4 ] ) . at ( 0 , 2 ) ) . toEqual ( [ 2 , 4 ] ) ;
309
+ it ( "returns updated array " , function ( ) {
310
+ expect ( ba ( [ 2 , 3 , 4 ] ) . $set ( 1 , "three" ) ) . toEqual ( [ 2 , "three" , 4 ] ) ;
299
311
} ) ;
300
312
} ) ;
301
313
0 commit comments