Skip to content

Update test case polygons so some should fail when lat / long is used… #4608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions spec/ParsePolygon.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const defaultHeaders = {

describe('Parse.Polygon testing', () => {
it('polygon save open path', (done) => {
const coords = [[0,0],[0,1],[1,1],[1,0]];
const closed = [[0,0],[0,1],[1,1],[1,0],[0,0]];
const coords = [[0,0],[0,1],[1,2],[1,0]];
const closed = [[0,0],[0,1],[1,2],[1,0],[0,0]];
const obj = new TestObject();
obj.set('polygon', new Parse.Polygon(coords));
return obj.save().then(() => {
Expand All @@ -25,7 +25,7 @@ describe('Parse.Polygon testing', () => {
});

it('polygon save closed path', (done) => {
const coords = [[0,0],[0,1],[1,1],[1,0],[0,0]];
const coords = [[0,0],[0,1],[1,2],[1,0],[0,0]];
const obj = new TestObject();
obj.set('polygon', new Parse.Polygon(coords));
return obj.save().then(() => {
Expand All @@ -40,8 +40,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 openPoints = [[0,0],[0,1],[1,2],[1,0]];
const closedPoints = [[0,0],[0,1],[1,2],[1,0],[0,0]];
const openPolygon = new Parse.Polygon(openPoints);
const closedPolygon = new Parse.Polygon(closedPoints);
const obj = new TestObject();
Expand All @@ -66,9 +66,9 @@ describe('Parse.Polygon testing', () => {
});

it('polygon update', (done) => {
const oldCoords = [[0,0],[0,1],[1,1],[1,0]];
const oldCoords = [[0,0],[0,1],[1,2],[1,0]];
const oldPolygon = new Parse.Polygon(oldCoords);
const newCoords = [[2,2],[2,3],[3,3],[3,2]];
const newCoords = [[2,2],[2,3],[3,5],[3,2]];
const newPolygon = new Parse.Polygon(newCoords);
const obj = new TestObject();
obj.set('polygon', oldPolygon);
Expand All @@ -88,7 +88,7 @@ describe('Parse.Polygon testing', () => {
});

it('polygon invalid value', (done) => {
const coords = [['foo','bar'],[0,1],[1,0],[1,1],[0,0]];
const coords = [['foo','bar'],[0,1],[1,0],[1,2],[0,0]];
const obj = new TestObject();
obj.set('polygon', {__type: 'Polygon', coordinates: coords});
return obj.save().then(() => {
Expand Down Expand Up @@ -129,7 +129,7 @@ describe('Parse.Polygon testing', () => {
});

it('polygonContain query', (done) => {
const points1 = [[0,0],[0,1],[1,1],[1,0]];
Copy link
Author

@JacobJT JacobJT Mar 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the most important change. If the coordinates of either the polygon or the coordinate we are seeing if is contained within the polygon are reversed from what we intend, the check will fail. To be frank, many of the other changes may be completely moot, as they seem to be just validating data that exists and doesn't criss / cross. In all likelihood, everything but this line change could be scrapped to highlight the same results

const points1 = [[.25,0],[.25,1.25],[.75,1.25],[.75,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 = new Parse.Polygon(points1);
Expand All @@ -142,7 +142,7 @@ describe('Parse.Polygon testing', () => {
const where = {
location: {
$geoIntersects: {
$point: { __type: 'GeoPoint', latitude: 0.5, longitude: 0.5 }
$point: { __type: 'GeoPoint', latitude: 0.5, longitude:1.0 }
}
}
};
Expand Down Expand Up @@ -184,7 +184,7 @@ describe('Parse.Polygon testing', () => {
});

it('polygonContain invalid geoPoint', (done) => {
const points = [[0,0],[0,1],[1,1],[1,0]];
const points = [[0,0],[0,1],[1,2],[1,0]];
const polygon = new Parse.Polygon(points);
const obj = new TestObject({location: polygon});
obj.save().then(() => {
Expand All @@ -209,7 +209,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]];
const coords = [[0,0],[0,1],[1,2],[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};
Expand Down Expand Up @@ -256,7 +256,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 coords = [[0,0],[0,1],[1,0],[1,2]];
const obj = new TestObject();
obj.set('polygon', new Parse.Polygon(coords));
obj.save().then(done.fail, done);
Expand Down