@@ -22,6 +22,7 @@ jest.dontMock('../ParseFile');
2222jest . dontMock ( '../ParseGeoPoint' ) ;
2323jest . dontMock ( '../ParseObject' ) ;
2424jest . dontMock ( '../ParseOp' ) ;
25+ jest . dontMock ( '../ParsePolygon' ) ;
2526jest . dontMock ( '../ParseRelation' ) ;
2627jest . dontMock ( '../RESTController' ) ;
2728jest . dontMock ( '../SingleInstanceStateController' ) ;
@@ -147,6 +148,7 @@ const ParseACL = require('../ParseACL').default;
147148const ParseError = require ( '../ParseError' ) . default ;
148149const ParseFile = require ( '../ParseFile' ) . default ;
149150const ParseGeoPoint = require ( '../ParseGeoPoint' ) . default ;
151+ const ParsePolygon = require ( '../ParsePolygon' ) . default ;
150152const ParseObject = require ( '../ParseObject' ) . default ;
151153const ParseOp = require ( '../ParseOp' ) ;
152154const RESTController = require ( '../RESTController' ) ;
@@ -1104,6 +1106,40 @@ describe('ParseObject', () => {
11041106 expect ( p . op ( 'age' ) ) . toBe ( undefined ) ;
11051107 } ) ;
11061108
1109+ it ( 'handle GeoPoint changes for server' , ( ) => {
1110+ const p = new ParseObject ( 'Person' ) ;
1111+ p . id = 'PPoint' ;
1112+ const created = new Date ( ) ;
1113+ const geopoint = new ParseGeoPoint ( 0 , 0 ) ;
1114+ p . _handleSaveResponse ( {
1115+ createdAt : created . toISOString ( ) ,
1116+ point : geopoint . toJSON ( ) ,
1117+ } ) ;
1118+ expect ( p . _getServerData ( ) ) . toEqual ( {
1119+ updatedAt : created ,
1120+ createdAt : created ,
1121+ point : geopoint ,
1122+ } ) ;
1123+ expect ( p . _getServerData ( ) . point instanceof ParseGeoPoint ) . toBe ( true ) ;
1124+ } ) ;
1125+
1126+ it ( 'handle Polygon changes for server' , ( ) => {
1127+ const p = new ParseObject ( 'Person' ) ;
1128+ p . id = 'PPolygon' ;
1129+ const created = new Date ( ) ;
1130+ const polygon = new ParsePolygon ( [ [ 0 , 0 ] , [ 0 , 1 ] , [ 1 , 1 ] , [ 1 , 0 ] , [ 0 , 0 ] ] ) ;
1131+ p . _handleSaveResponse ( {
1132+ createdAt : created . toISOString ( ) ,
1133+ shape : polygon . toJSON ( ) ,
1134+ } ) ;
1135+ expect ( p . _getServerData ( ) ) . toEqual ( {
1136+ updatedAt : created ,
1137+ createdAt : created ,
1138+ shape : polygon ,
1139+ } ) ;
1140+ expect ( p . _getServerData ( ) . shape instanceof ParsePolygon ) . toBe ( true ) ;
1141+ } ) ;
1142+
11071143 it ( 'handle createdAt string for server' , ( ) => {
11081144 const p = new ParseObject ( 'Person' ) ;
11091145 p . id = 'P9' ;
0 commit comments