Skip to content

Commit c51ead2

Browse files
committed
Bumps Parse to 1.10.1
Updates Polygon test suite to leverage latest version
1 parent 6e37ea2 commit c51ead2

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"mime": "1.4.0",
3030
"mongodb": "2.2.31",
3131
"multer": "1.3.0",
32-
"parse": "1.10.0",
32+
"parse": "1.10.1",
3333
"parse-server-fs-adapter": "1.0.1",
3434
"parse-server-push-adapter": "2.0.0",
3535
"parse-server-s3-adapter": "1.2.0",

spec/ParsePolygon.spec.js

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ describe('Parse.Polygon testing', () => {
1212
const coords = [[0,0],[0,1],[1,1],[1,0]];
1313
const closed = [[0,0],[0,1],[1,1],[1,0],[0,0]];
1414
const obj = new TestObject();
15-
obj.set('polygon', {__type: 'Polygon', coordinates: coords});
15+
obj.set('polygon', new Parse.Polygon(coords));
1616
return obj.save().then(() => {
1717
const query = new Parse.Query(TestObject);
1818
return query.get(obj.id);
1919
}).then((result) => {
2020
const polygon = result.get('polygon');
21-
equal(polygon.__type, 'Polygon');
21+
equal(polygon instanceof Parse.Polygon, true);
2222
equal(polygon.coordinates, closed);
2323
done();
2424
}, done.fail);
@@ -27,13 +27,13 @@ describe('Parse.Polygon testing', () => {
2727
it('polygon save closed path', (done) => {
2828
const coords = [[0,0],[0,1],[1,1],[1,0],[0,0]];
2929
const obj = new TestObject();
30-
obj.set('polygon', {__type: 'Polygon', coordinates: coords});
30+
obj.set('polygon', new Parse.Polygon(coords));
3131
return obj.save().then(() => {
3232
const query = new Parse.Query(TestObject);
3333
return query.get(obj.id);
3434
}).then((result) => {
3535
const polygon = result.get('polygon');
36-
equal(polygon.__type, 'Polygon');
36+
equal(polygon instanceof Parse.Polygon, true);
3737
equal(polygon.coordinates, coords);
3838
done();
3939
}, done.fail);
@@ -42,8 +42,8 @@ describe('Parse.Polygon testing', () => {
4242
it('polygon equalTo (open/closed) path', (done) => {
4343
const openPoints = [[0,0],[0,1],[1,1],[1,0]];
4444
const closedPoints = [[0,0],[0,1],[1,1],[1,0],[0,0]];
45-
const openPolygon = {__type: 'Polygon', coordinates: openPoints};
46-
const closedPolygon = {__type: 'Polygon', coordinates: closedPoints};
45+
const openPolygon = new Parse.Polygon(openPoints);
46+
const closedPolygon = new Parse.Polygon(closedPoints);
4747
const obj = new TestObject();
4848
obj.set('polygon', openPolygon);
4949
return obj.save().then(() => {
@@ -52,24 +52,24 @@ describe('Parse.Polygon testing', () => {
5252
return query.find();
5353
}).then((results) => {
5454
const polygon = results[0].get('polygon');
55-
equal(polygon.__type, 'Polygon');
55+
equal(polygon instanceof Parse.Polygon, true);
5656
equal(polygon.coordinates, closedPoints);
5757
const query = new Parse.Query(TestObject);
5858
query.equalTo('polygon', closedPolygon);
5959
return query.find();
6060
}).then((results) => {
6161
const polygon = results[0].get('polygon');
62-
equal(polygon.__type, 'Polygon');
62+
equal(polygon instanceof Parse.Polygon, true);
6363
equal(polygon.coordinates, closedPoints);
6464
done();
6565
}, done.fail);
6666
});
6767

6868
it('polygon update', (done) => {
6969
const oldCoords = [[0,0],[0,1],[1,1],[1,0]];
70-
const oldPolygon = {__type: 'Polygon', coordinates: oldCoords};
70+
const oldPolygon = new Parse.Polygon(oldCoords);
7171
const newCoords = [[2,2],[2,3],[3,3],[3,2]];
72-
const newPolygon = {__type: 'Polygon', coordinates: newCoords};
72+
const newPolygon = new Parse.Polygon(newCoords);
7373
const obj = new TestObject();
7474
obj.set('polygon', oldPolygon);
7575
return obj.save().then(() => {
@@ -81,7 +81,7 @@ describe('Parse.Polygon testing', () => {
8181
}).then((result) => {
8282
const polygon = result.get('polygon');
8383
newCoords.push(newCoords[0]);
84-
equal(polygon.__type, 'Polygon');
84+
equal(polygon instanceof Parse.Polygon, true);
8585
equal(polygon.coordinates, newCoords);
8686
done();
8787
}, done.fail);
@@ -100,28 +100,29 @@ describe('Parse.Polygon testing', () => {
100100
it('polygon three points minimum', (done) => {
101101
const coords = [[0,0]];
102102
const obj = new TestObject();
103+
// use raw so we test the server validates properly
103104
obj.set('polygon', {__type: 'Polygon', coordinates: coords});
104105
obj.save().then(done.fail, done);
105106
});
106107

107108
it('polygon three different points minimum', (done) => {
108109
const coords = [[0,0],[0,1],[0,0]];
109110
const obj = new TestObject();
110-
obj.set('polygon', {__type: 'Polygon', coordinates: coords});
111+
obj.set('polygon', new Parse.Polygon(coords));
111112
obj.save().then(done.fail, done);
112113
});
113114

114115
it('polygon counterclockwise', (done) => {
115116
const coords = [[1,1],[0,1],[0,0],[1,0]];
116117
const closed = [[1,1],[0,1],[0,0],[1,0],[1,1]];
117118
const obj = new TestObject();
118-
obj.set('polygon', {__type: 'Polygon', coordinates: coords});
119+
obj.set('polygon', new Parse.Polygon(coords));
119120
obj.save().then(() => {
120121
const query = new Parse.Query(TestObject);
121122
return query.get(obj.id);
122123
}).then((result) => {
123124
const polygon = result.get('polygon');
124-
equal(polygon.__type, 'Polygon');
125+
equal(polygon instanceof Parse.Polygon, true);
125126
equal(polygon.coordinates, closed);
126127
done();
127128
}, done.fail);
@@ -131,9 +132,9 @@ describe('Parse.Polygon testing', () => {
131132
const points1 = [[0,0],[0,1],[1,1],[1,0]];
132133
const points2 = [[0,0],[0,2],[2,2],[2,0]];
133134
const points3 = [[10,10],[10,15],[15,15],[15,10],[10,10]];
134-
const polygon1 = {__type: 'Polygon', coordinates: points1};
135-
const polygon2 = {__type: 'Polygon', coordinates: points2};
136-
const polygon3 = {__type: 'Polygon', coordinates: points3};
135+
const polygon1 = new Parse.Polygon(points1);
136+
const polygon2 = new Parse.Polygon(points2);
137+
const polygon3 = new Parse.Polygon(points3);
137138
const obj1 = new TestObject({location: polygon1});
138139
const obj2 = new TestObject({location: polygon2});
139140
const obj3 = new TestObject({location: polygon3});
@@ -161,7 +162,7 @@ describe('Parse.Polygon testing', () => {
161162

162163
it('polygonContain invalid input', (done) => {
163164
const points = [[0,0],[0,1],[1,1],[1,0]];
164-
const polygon = {__type: 'Polygon', coordinates: points};
165+
const polygon = new Parse.Polygon(points);
165166
const obj = new TestObject({location: polygon});
166167
obj.save().then(() => {
167168
const where = {
@@ -184,7 +185,7 @@ describe('Parse.Polygon testing', () => {
184185

185186
it('polygonContain invalid geoPoint', (done) => {
186187
const points = [[0,0],[0,1],[1,1],[1,0]];
187-
const polygon = {__type: 'Polygon', coordinates: points};
188+
const polygon = new Parse.Polygon(points);
188189
const obj = new TestObject({location: polygon});
189190
obj.save().then(() => {
190191
const where = {
@@ -209,6 +210,7 @@ describe('Parse.Polygon testing', () => {
209210
describe_only_db('mongo')('Parse.Polygon testing', () => {
210211
it('support 2d and 2dsphere', (done) => {
211212
const coords = [[0,0],[0,1],[1,1],[1,0],[0,0]];
213+
// testings against REST API, use raw formats
212214
const polygon = {__type: 'Polygon', coordinates: coords};
213215
const location = {__type: 'GeoPoint', latitude:10, longitude:10};
214216
const databaseAdapter = new MongoStorageAdapter({ uri: mongoURI });
@@ -256,7 +258,7 @@ describe_only_db('mongo')('Parse.Polygon testing', () => {
256258
it('polygon loop is not valid', (done) => {
257259
const coords = [[0,0],[0,1],[1,0],[1,1]];
258260
const obj = new TestObject();
259-
obj.set('polygon', {__type: 'Polygon', coordinates: coords});
261+
obj.set('polygon', new Parse.Polygon(coords));
260262
obj.save().then(done.fail, done);
261263
});
262264
});

0 commit comments

Comments
 (0)