File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -283,10 +283,12 @@ function encodeValue(value) {
283283 return valueProto ;
284284 }
285285
286- if ( is . object ( value ) && ! is . empty ( value ) ) {
287- for ( var prop in value ) {
288- if ( value . hasOwnProperty ( prop ) ) {
289- value [ prop ] = entity . encodeValue ( value [ prop ] ) ;
286+ if ( is . object ( value ) ) {
287+ if ( ! is . empty ( value ) ) {
288+ for ( var prop in value ) {
289+ if ( value . hasOwnProperty ( prop ) ) {
290+ value [ prop ] = entity . encodeValue ( value [ prop ] ) ;
291+ }
290292 }
291293 }
292294
Original file line number Diff line number Diff line change @@ -430,9 +430,21 @@ describe('entity', function() {
430430 assert . deepEqual ( entity . encodeValue ( value ) , expectedValueProto ) ;
431431 } ) ;
432432
433+ it ( 'should encode an empty object' , function ( ) {
434+ var value = { } ;
435+
436+ var expectedValueProto = {
437+ entityValue : {
438+ properties : { }
439+ }
440+ } ;
441+
442+ assert . deepEqual ( entity . encodeValue ( value ) , expectedValueProto ) ;
443+ } ) ;
444+
433445 it ( 'should throw if an invalid value was provided' , function ( ) {
434446 assert . throws ( function ( ) {
435- entity . encodeValue ( { } ) ;
447+ entity . encodeValue ( ) ;
436448 } , / U n s u p p o r t e d f i e l d v a l u e / ) ;
437449 } ) ;
438450 } ) ;
You can’t perform that action at this time.
0 commit comments