@@ -78,6 +78,14 @@ describe('update', function() {
7878 expect ( update ( { a : 'b' } , { $set : { c : 'd' } } ) ) . toEqual ( { c : 'd' } ) ;
7979 } ) ;
8080
81+ it ( 'should support apply' , function ( ) {
82+ expect ( update ( 2 , { $apply : function ( x ) { return x * 2 ; } } ) ) . toEqual ( 4 ) ;
83+ expect ( update . bind ( null , 2 , { $apply : 123 } ) ) . toThrow (
84+ 'Invariant Violation: update(): expected spec of $apply to be a ' +
85+ 'function; got 123.'
86+ ) ;
87+ } ) ;
88+
8189 it ( 'should support deep updates' , function ( ) {
8290 expect ( update ( { a : 'b' , c : { d : 'e' } } , { c : { d : { $set : 'f' } } } ) ) . toEqual ( {
8391 a : 'b' ,
@@ -88,8 +96,8 @@ describe('update', function() {
8896 it ( 'should require a command' , function ( ) {
8997 expect ( update . bind ( null , { a : 'b' } , { a : 'c' } ) ) . toThrow (
9098 'Invariant Violation: update(): You provided a key path to update() ' +
91- 'that did not contain one of $push, $unshift, $splice, $set, $merge. ' +
92- 'Did you forget to include {$set: ...}?'
99+ 'that did not contain one of $push, $unshift, $splice, $set, $merge, ' +
100+ '$apply. Did you forget to include {$set: ...}?'
93101 ) ;
94102 } ) ;
95103} ) ;
0 commit comments