@@ -22,6 +22,7 @@ jest.dontMock('../ParseFile');
22
22
jest . dontMock ( '../ParseGeoPoint' ) ;
23
23
jest . dontMock ( '../ParseObject' ) ;
24
24
jest . dontMock ( '../ParseOp' ) ;
25
+ jest . dontMock ( '../ParsePolygon' ) ;
25
26
jest . dontMock ( '../ParseRelation' ) ;
26
27
jest . dontMock ( '../RESTController' ) ;
27
28
jest . dontMock ( '../SingleInstanceStateController' ) ;
@@ -147,6 +148,7 @@ const ParseACL = require('../ParseACL').default;
147
148
const ParseError = require ( '../ParseError' ) . default ;
148
149
const ParseFile = require ( '../ParseFile' ) . default ;
149
150
const ParseGeoPoint = require ( '../ParseGeoPoint' ) . default ;
151
+ const ParsePolygon = require ( '../ParsePolygon' ) . default ;
150
152
const ParseObject = require ( '../ParseObject' ) . default ;
151
153
const ParseOp = require ( '../ParseOp' ) ;
152
154
const RESTController = require ( '../RESTController' ) ;
@@ -1104,6 +1106,40 @@ describe('ParseObject', () => {
1104
1106
expect ( p . op ( 'age' ) ) . toBe ( undefined ) ;
1105
1107
} ) ;
1106
1108
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
+
1107
1143
it ( 'handle createdAt string for server' , ( ) => {
1108
1144
const p = new ParseObject ( 'Person' ) ;
1109
1145
p . id = 'P9' ;
0 commit comments