@@ -292,22 +292,24 @@ describe('Observer', function () {
292292
293293 describe ( 'Augmentations' , function ( ) {
294294
295- it ( '$remove (index) ' , function ( ) {
295+ it ( '$set ' , function ( ) {
296296 var emitted = false ,
297297 index = ~ ~ ( Math . random ( ) * arr . length ) ,
298- expected = arr [ index ] = { a : 1 }
298+ expected = arr [ index ] = { a : 1 } ,
299+ arg = 34567
299300 ob . once ( 'mutate' , function ( key , array , mutation ) {
300301 emitted = true
301302 assert . strictEqual ( mutation . method , 'splice' )
302- assert . strictEqual ( mutation . args . length , 2 )
303+ assert . strictEqual ( mutation . args . length , 3 )
303304 assert . strictEqual ( mutation . args [ 0 ] , index )
304305 } )
305- var r = arr . $remove ( index )
306+ var r = arr . $set ( index , arg )
306307 assert . ok ( emitted )
307308 assert . strictEqual ( r , expected )
309+ assert . strictEqual ( arr [ index ] , arg )
308310 } )
309-
310- it ( '$remove (object )' , function ( ) {
311+
312+ it ( '$remove (index )' , function ( ) {
311313 var emitted = false ,
312314 index = ~ ~ ( Math . random ( ) * arr . length ) ,
313315 expected = arr [ index ] = { a : 1 }
@@ -317,70 +319,24 @@ describe('Observer', function () {
317319 assert . strictEqual ( mutation . args . length , 2 )
318320 assert . strictEqual ( mutation . args [ 0 ] , index )
319321 } )
320- var r = arr . $remove ( expected )
321- assert . ok ( emitted )
322- assert . strictEqual ( r , expected )
323- } )
324-
325- it ( '$remove (function)' , function ( ) {
326- var expected = [ 1001 , 1002 ]
327- arr . push . apply ( arr , expected )
328- var filter = function ( e ) {
329- return e > 1000
330- } ,
331- copy = arr . filter ( function ( e ) {
332- return e <= 1000
333- } )
334- var removed = arr . $remove ( filter )
335- assert . deepEqual ( arr , copy )
336- assert . deepEqual ( expected , removed )
337- } )
338-
339- it ( '$replace (index)' , function ( ) {
340- var emitted = false ,
341- index = ~ ~ ( Math . random ( ) * arr . length ) ,
342- expected = arr [ index ] = { a : 1 } ,
343- arg = 34567
344- ob . once ( 'mutate' , function ( key , array , mutation ) {
345- emitted = true
346- assert . strictEqual ( mutation . method , 'splice' )
347- assert . strictEqual ( mutation . args . length , 3 )
348- assert . strictEqual ( mutation . args [ 0 ] , index )
349- } )
350- var r = arr . $replace ( index , arg )
322+ var r = arr . $remove ( index )
351323 assert . ok ( emitted )
352324 assert . strictEqual ( r , expected )
353- assert . strictEqual ( arr [ index ] , arg )
354325 } )
355-
356- it ( '$replace (object)' , function ( ) {
326+
327+ it ( '$remove (object)' , function ( ) {
357328 var emitted = false ,
358329 index = ~ ~ ( Math . random ( ) * arr . length ) ,
359- expected = arr [ index ] = { a : 1 } ,
360- arg = 45678
330+ expected = arr [ index ] = { a : 1 }
361331 ob . once ( 'mutate' , function ( key , array , mutation ) {
362332 emitted = true
363333 assert . strictEqual ( mutation . method , 'splice' )
364- assert . strictEqual ( mutation . args . length , 3 )
334+ assert . strictEqual ( mutation . args . length , 2 )
365335 assert . strictEqual ( mutation . args [ 0 ] , index )
366336 } )
367- var r = arr . $replace ( expected , arg )
337+ var r = arr . $remove ( expected )
368338 assert . ok ( emitted )
369339 assert . strictEqual ( r , expected )
370- assert . strictEqual ( arr [ index ] , arg )
371- } )
372-
373- it ( '$replace (function)' , function ( ) {
374- arr [ 0 ] = 1
375- arr [ 1 ] = 2
376- arr [ 2 ] = 3
377- var expected = [ 2 , 3 , 3 ] ,
378- expectRet = [ 1 , 2 ]
379- var replaced = arr . $replace ( function ( e ) {
380- if ( e < 3 ) return e + 1
381- } )
382- assert . deepEqual ( arr , expected )
383- assert . deepEqual ( replaced , expectRet )
384340 } )
385341
386342 } )
0 commit comments