Bumps parse sdk 1.10.1 (#4274)

* Fail test case for Issue#3999

* no message

* Bumps Parse to 1.10.1

Updates Polygon test suite to leverage latest version
This commit is contained in:
Florent Vilmart
2017-10-21 16:03:24 -04:00
committed by GitHub
parent 31bd02ce5c
commit e4eeadd4c6
3 changed files with 45 additions and 21 deletions

View File

@@ -12,13 +12,13 @@ describe('Parse.Polygon testing', () => {
const coords = [[0,0],[0,1],[1,1],[1,0]];
const closed = [[0,0],[0,1],[1,1],[1,0],[0,0]];
const obj = new TestObject();
obj.set('polygon', {__type: 'Polygon', coordinates: coords});
obj.set('polygon', new Parse.Polygon(coords));
return obj.save().then(() => {
const query = new Parse.Query(TestObject);
return query.get(obj.id);
}).then((result) => {
const polygon = result.get('polygon');
equal(polygon.__type, 'Polygon');
equal(polygon instanceof Parse.Polygon, true);
equal(polygon.coordinates, closed);
done();
}, done.fail);
@@ -27,13 +27,13 @@ describe('Parse.Polygon testing', () => {
it('polygon save closed path', (done) => {
const coords = [[0,0],[0,1],[1,1],[1,0],[0,0]];
const obj = new TestObject();
obj.set('polygon', {__type: 'Polygon', coordinates: coords});
obj.set('polygon', new Parse.Polygon(coords));
return obj.save().then(() => {
const query = new Parse.Query(TestObject);
return query.get(obj.id);
}).then((result) => {
const polygon = result.get('polygon');
equal(polygon.__type, 'Polygon');
equal(polygon instanceof Parse.Polygon, true);
equal(polygon.coordinates, coords);
done();
}, done.fail);
@@ -42,8 +42,8 @@ describe('Parse.Polygon testing', () => {
it('polygon equalTo (open/closed) path', (done) => {
const openPoints = [[0,0],[0,1],[1,1],[1,0]];
const closedPoints = [[0,0],[0,1],[1,1],[1,0],[0,0]];
const openPolygon = {__type: 'Polygon', coordinates: openPoints};
const closedPolygon = {__type: 'Polygon', coordinates: closedPoints};
const openPolygon = new Parse.Polygon(openPoints);
const closedPolygon = new Parse.Polygon(closedPoints);
const obj = new TestObject();
obj.set('polygon', openPolygon);
return obj.save().then(() => {
@@ -52,14 +52,14 @@ describe('Parse.Polygon testing', () => {
return query.find();
}).then((results) => {
const polygon = results[0].get('polygon');
equal(polygon.__type, 'Polygon');
equal(polygon instanceof Parse.Polygon, true);
equal(polygon.coordinates, closedPoints);
const query = new Parse.Query(TestObject);
query.equalTo('polygon', closedPolygon);
return query.find();
}).then((results) => {
const polygon = results[0].get('polygon');
equal(polygon.__type, 'Polygon');
equal(polygon instanceof Parse.Polygon, true);
equal(polygon.coordinates, closedPoints);
done();
}, done.fail);
@@ -67,9 +67,9 @@ describe('Parse.Polygon testing', () => {
it('polygon update', (done) => {
const oldCoords = [[0,0],[0,1],[1,1],[1,0]];
const oldPolygon = {__type: 'Polygon', coordinates: oldCoords};
const oldPolygon = new Parse.Polygon(oldCoords);
const newCoords = [[2,2],[2,3],[3,3],[3,2]];
const newPolygon = {__type: 'Polygon', coordinates: newCoords};
const newPolygon = new Parse.Polygon(newCoords);
const obj = new TestObject();
obj.set('polygon', oldPolygon);
return obj.save().then(() => {
@@ -81,7 +81,7 @@ describe('Parse.Polygon testing', () => {
}).then((result) => {
const polygon = result.get('polygon');
newCoords.push(newCoords[0]);
equal(polygon.__type, 'Polygon');
equal(polygon instanceof Parse.Polygon, true);
equal(polygon.coordinates, newCoords);
done();
}, done.fail);
@@ -100,6 +100,7 @@ describe('Parse.Polygon testing', () => {
it('polygon three points minimum', (done) => {
const coords = [[0,0]];
const obj = new TestObject();
// use raw so we test the server validates properly
obj.set('polygon', {__type: 'Polygon', coordinates: coords});
obj.save().then(done.fail, done);
});
@@ -107,7 +108,7 @@ describe('Parse.Polygon testing', () => {
it('polygon three different points minimum', (done) => {
const coords = [[0,0],[0,1],[0,0]];
const obj = new TestObject();
obj.set('polygon', {__type: 'Polygon', coordinates: coords});
obj.set('polygon', new Parse.Polygon(coords));
obj.save().then(done.fail, done);
});
@@ -115,13 +116,13 @@ describe('Parse.Polygon testing', () => {
const coords = [[1,1],[0,1],[0,0],[1,0]];
const closed = [[1,1],[0,1],[0,0],[1,0],[1,1]];
const obj = new TestObject();
obj.set('polygon', {__type: 'Polygon', coordinates: coords});
obj.set('polygon', new Parse.Polygon(coords));
obj.save().then(() => {
const query = new Parse.Query(TestObject);
return query.get(obj.id);
}).then((result) => {
const polygon = result.get('polygon');
equal(polygon.__type, 'Polygon');
equal(polygon instanceof Parse.Polygon, true);
equal(polygon.coordinates, closed);
done();
}, done.fail);
@@ -131,9 +132,9 @@ describe('Parse.Polygon testing', () => {
const points1 = [[0,0],[0,1],[1,1],[1,0]];
const points2 = [[0,0],[0,2],[2,2],[2,0]];
const points3 = [[10,10],[10,15],[15,15],[15,10],[10,10]];
const polygon1 = {__type: 'Polygon', coordinates: points1};
const polygon2 = {__type: 'Polygon', coordinates: points2};
const polygon3 = {__type: 'Polygon', coordinates: points3};
const polygon1 = new Parse.Polygon(points1);
const polygon2 = new Parse.Polygon(points2);
const polygon3 = new Parse.Polygon(points3);
const obj1 = new TestObject({location: polygon1});
const obj2 = new TestObject({location: polygon2});
const obj3 = new TestObject({location: polygon3});
@@ -161,7 +162,7 @@ describe('Parse.Polygon testing', () => {
it('polygonContain invalid input', (done) => {
const points = [[0,0],[0,1],[1,1],[1,0]];
const polygon = {__type: 'Polygon', coordinates: points};
const polygon = new Parse.Polygon(points);
const obj = new TestObject({location: polygon});
obj.save().then(() => {
const where = {
@@ -184,7 +185,7 @@ describe('Parse.Polygon testing', () => {
it('polygonContain invalid geoPoint', (done) => {
const points = [[0,0],[0,1],[1,1],[1,0]];
const polygon = {__type: 'Polygon', coordinates: points};
const polygon = new Parse.Polygon(points);
const obj = new TestObject({location: polygon});
obj.save().then(() => {
const where = {
@@ -209,6 +210,7 @@ describe('Parse.Polygon testing', () => {
describe_only_db('mongo')('Parse.Polygon testing', () => {
it('support 2d and 2dsphere', (done) => {
const coords = [[0,0],[0,1],[1,1],[1,0],[0,0]];
// testings against REST API, use raw formats
const polygon = {__type: 'Polygon', coordinates: coords};
const location = {__type: 'GeoPoint', latitude:10, longitude:10};
const databaseAdapter = new MongoStorageAdapter({ uri: mongoURI });
@@ -256,7 +258,7 @@ describe_only_db('mongo')('Parse.Polygon testing', () => {
it('polygon loop is not valid', (done) => {
const coords = [[0,0],[0,1],[1,0],[1,1]];
const obj = new TestObject();
obj.set('polygon', {__type: 'Polygon', coordinates: coords});
obj.set('polygon', new Parse.Polygon(coords));
obj.save().then(done.fail, done);
});
});

View File

@@ -3086,4 +3086,26 @@ describe('Parse.Query testing', () => {
done();
}, done.fail);
});
it('should not interfere with has when using select on field with undefined value #3999', (done) => {
const obj1 = new Parse.Object('TestObject');
const obj2 = new Parse.Object('OtherObject');
obj2.set('otherField', 1);
obj1.set('testPointerField', obj2);
obj1.set('shouldBe', true);
const obj3 = new Parse.Object('TestObject');
obj3.set('shouldBe', false);
Parse.Object.saveAll([obj1, obj3]).then(() => {
const query = new Parse.Query('TestObject');
query.include('testPointerField');
query.select(['testPointerField', 'testPointerField.otherField', 'shouldBe']);
return query.find();
}).then(results => {
results.forEach(result => {
equal(result.has('testPointerField'), result.get('shouldBe'));
});
done();
}
).catch(done.fail);
});
});