chore(package): update jasmine to version 3.0.0 (#4553)
* chore(package): update jasmine to version 3.0.0 Closes #4547 * Fixes failing tests for jasmine 3.0 Starting 3.0, done(something) will fail * Update tests so they dont leverage var, but let and const With jasmine 3.0, the randomization engine was making the test fails because of the scope of `var` * Remove randomizer * Use same adapter for PG tests, drop table to ensure the tests dont side effect
This commit is contained in:
@@ -2,22 +2,22 @@
|
||||
// hungry/js/test/parse_geo_point_test.js
|
||||
|
||||
const rp = require('request-promise');
|
||||
var TestObject = Parse.Object.extend('TestObject');
|
||||
const TestObject = Parse.Object.extend('TestObject');
|
||||
|
||||
describe('Parse.GeoPoint testing', () => {
|
||||
|
||||
it('geo point roundtrip', (done) => {
|
||||
var point = new Parse.GeoPoint(44.0, -11.0);
|
||||
var obj = new TestObject();
|
||||
const point = new Parse.GeoPoint(44.0, -11.0);
|
||||
const obj = new TestObject();
|
||||
obj.set('location', point);
|
||||
obj.set('name', 'Ferndale');
|
||||
obj.save(null, {
|
||||
success: function() {
|
||||
var query = new Parse.Query(TestObject);
|
||||
const query = new Parse.Query(TestObject);
|
||||
query.find({
|
||||
success: function(results) {
|
||||
equal(results.length, 1);
|
||||
var pointAgain = results[0].get('location');
|
||||
const pointAgain = results[0].get('location');
|
||||
ok(pointAgain);
|
||||
equal(pointAgain.latitude, 44.0);
|
||||
equal(pointAgain.longitude, -11.0);
|
||||
@@ -37,7 +37,7 @@ describe('Parse.GeoPoint testing', () => {
|
||||
obj.set('location', newPoint);
|
||||
return obj.save();
|
||||
}).then(() => {
|
||||
var query = new Parse.Query(TestObject);
|
||||
const query = new Parse.Query(TestObject);
|
||||
return query.get(obj.id);
|
||||
}).then((result) => {
|
||||
const point = result.get('location');
|
||||
@@ -48,8 +48,8 @@ describe('Parse.GeoPoint testing', () => {
|
||||
});
|
||||
|
||||
it('has the correct __type field in the json response', done => {
|
||||
var point = new Parse.GeoPoint(44.0, -11.0);
|
||||
var obj = new TestObject();
|
||||
const point = new Parse.GeoPoint(44.0, -11.0);
|
||||
const obj = new TestObject();
|
||||
obj.set('location', point);
|
||||
obj.set('name', 'Zhoul')
|
||||
obj.save(null, {
|
||||
@@ -69,8 +69,8 @@ describe('Parse.GeoPoint testing', () => {
|
||||
});
|
||||
|
||||
it('creating geo point exception two fields', (done) => {
|
||||
var point = new Parse.GeoPoint(20, 20);
|
||||
var obj = new TestObject();
|
||||
const point = new Parse.GeoPoint(20, 20);
|
||||
const obj = new TestObject();
|
||||
obj.set('locationOne', point);
|
||||
obj.set('locationTwo', point);
|
||||
obj.save().then(() => {
|
||||
@@ -83,8 +83,8 @@ describe('Parse.GeoPoint testing', () => {
|
||||
|
||||
// TODO: This should also have support in postgres, or higher level database agnostic support.
|
||||
it_exclude_dbs(['postgres'])('updating geo point exception two fields', (done) => {
|
||||
var point = new Parse.GeoPoint(20, 20);
|
||||
var obj = new TestObject();
|
||||
const point = new Parse.GeoPoint(20, 20);
|
||||
const obj = new TestObject();
|
||||
obj.set('locationOne', point);
|
||||
obj.save(null, {
|
||||
success: (obj) => {
|
||||
@@ -100,10 +100,10 @@ describe('Parse.GeoPoint testing', () => {
|
||||
});
|
||||
|
||||
it('geo line', (done) => {
|
||||
var line = [];
|
||||
for (var i = 0; i < 10; ++i) {
|
||||
var obj = new TestObject();
|
||||
var point = new Parse.GeoPoint(i * 4.0 - 12.0, i * 3.2 - 11.0);
|
||||
const line = [];
|
||||
for (let i = 0; i < 10; ++i) {
|
||||
const obj = new TestObject();
|
||||
const point = new Parse.GeoPoint(i * 4.0 - 12.0, i * 3.2 - 11.0);
|
||||
obj.set('location', point);
|
||||
obj.set('construct', 'line');
|
||||
obj.set('seq', i);
|
||||
@@ -111,8 +111,8 @@ describe('Parse.GeoPoint testing', () => {
|
||||
}
|
||||
Parse.Object.saveAll(line, {
|
||||
success: function() {
|
||||
var query = new Parse.Query(TestObject);
|
||||
var point = new Parse.GeoPoint(24, 19);
|
||||
const query = new Parse.Query(TestObject);
|
||||
const point = new Parse.GeoPoint(24, 19);
|
||||
query.equalTo('construct', 'line');
|
||||
query.withinMiles('location', point, 10000);
|
||||
query.find({
|
||||
@@ -128,17 +128,17 @@ describe('Parse.GeoPoint testing', () => {
|
||||
});
|
||||
|
||||
it('geo max distance large', (done) => {
|
||||
var objects = [];
|
||||
const objects = [];
|
||||
[0, 1, 2].map(function(i) {
|
||||
var obj = new TestObject();
|
||||
var point = new Parse.GeoPoint(0.0, i * 45.0);
|
||||
const obj = new TestObject();
|
||||
const point = new Parse.GeoPoint(0.0, i * 45.0);
|
||||
obj.set('location', point);
|
||||
obj.set('index', i);
|
||||
objects.push(obj);
|
||||
});
|
||||
Parse.Object.saveAll(objects).then(() => {
|
||||
var query = new Parse.Query(TestObject);
|
||||
var point = new Parse.GeoPoint(1.0, -1.0);
|
||||
const query = new Parse.Query(TestObject);
|
||||
const point = new Parse.GeoPoint(1.0, -1.0);
|
||||
query.withinRadians('location', point, 3.14);
|
||||
return query.find();
|
||||
}).then((results) => {
|
||||
@@ -151,17 +151,17 @@ describe('Parse.GeoPoint testing', () => {
|
||||
});
|
||||
|
||||
it('geo max distance medium', (done) => {
|
||||
var objects = [];
|
||||
const objects = [];
|
||||
[0, 1, 2].map(function(i) {
|
||||
var obj = new TestObject();
|
||||
var point = new Parse.GeoPoint(0.0, i * 45.0);
|
||||
const obj = new TestObject();
|
||||
const point = new Parse.GeoPoint(0.0, i * 45.0);
|
||||
obj.set('location', point);
|
||||
obj.set('index', i);
|
||||
objects.push(obj);
|
||||
});
|
||||
Parse.Object.saveAll(objects, function() {
|
||||
var query = new Parse.Query(TestObject);
|
||||
var point = new Parse.GeoPoint(1.0, -1.0);
|
||||
const query = new Parse.Query(TestObject);
|
||||
const point = new Parse.GeoPoint(1.0, -1.0);
|
||||
query.withinRadians('location', point, 3.14 * 0.5);
|
||||
query.find({
|
||||
success: function(results) {
|
||||
@@ -175,17 +175,17 @@ describe('Parse.GeoPoint testing', () => {
|
||||
});
|
||||
|
||||
it('geo max distance small', (done) => {
|
||||
var objects = [];
|
||||
const objects = [];
|
||||
[0, 1, 2].map(function(i) {
|
||||
var obj = new TestObject();
|
||||
var point = new Parse.GeoPoint(0.0, i * 45.0);
|
||||
const obj = new TestObject();
|
||||
const point = new Parse.GeoPoint(0.0, i * 45.0);
|
||||
obj.set('location', point);
|
||||
obj.set('index', i);
|
||||
objects.push(obj);
|
||||
});
|
||||
Parse.Object.saveAll(objects, function() {
|
||||
var query = new Parse.Query(TestObject);
|
||||
var point = new Parse.GeoPoint(1.0, -1.0);
|
||||
const query = new Parse.Query(TestObject);
|
||||
const point = new Parse.GeoPoint(1.0, -1.0);
|
||||
query.withinRadians('location', point, 3.14 * 0.25);
|
||||
query.find({
|
||||
success: function(results) {
|
||||
@@ -197,16 +197,16 @@ describe('Parse.GeoPoint testing', () => {
|
||||
});
|
||||
});
|
||||
|
||||
var makeSomeGeoPoints = function(callback) {
|
||||
var sacramento = new TestObject();
|
||||
const makeSomeGeoPoints = function(callback) {
|
||||
const sacramento = new TestObject();
|
||||
sacramento.set('location', new Parse.GeoPoint(38.52, -121.50));
|
||||
sacramento.set('name', 'Sacramento');
|
||||
|
||||
var honolulu = new TestObject();
|
||||
const honolulu = new TestObject();
|
||||
honolulu.set('location', new Parse.GeoPoint(21.35, -157.93));
|
||||
honolulu.set('name', 'Honolulu');
|
||||
|
||||
var sf = new TestObject();
|
||||
const sf = new TestObject();
|
||||
sf.set('location', new Parse.GeoPoint(37.75, -122.68));
|
||||
sf.set('name', 'San Francisco');
|
||||
|
||||
@@ -215,8 +215,8 @@ describe('Parse.GeoPoint testing', () => {
|
||||
|
||||
it('geo max distance in km everywhere', (done) => {
|
||||
makeSomeGeoPoints(function() {
|
||||
var sfo = new Parse.GeoPoint(37.6189722, -122.3748889);
|
||||
var query = new Parse.Query(TestObject);
|
||||
const sfo = new Parse.GeoPoint(37.6189722, -122.3748889);
|
||||
const query = new Parse.Query(TestObject);
|
||||
// Honolulu is 4300 km away from SFO on a sphere ;)
|
||||
query.withinKilometers('location', sfo, 4800.0);
|
||||
query.find({
|
||||
@@ -230,8 +230,8 @@ describe('Parse.GeoPoint testing', () => {
|
||||
|
||||
it('geo max distance in km california', (done) => {
|
||||
makeSomeGeoPoints(function() {
|
||||
var sfo = new Parse.GeoPoint(37.6189722, -122.3748889);
|
||||
var query = new Parse.Query(TestObject);
|
||||
const sfo = new Parse.GeoPoint(37.6189722, -122.3748889);
|
||||
const query = new Parse.Query(TestObject);
|
||||
query.withinKilometers('location', sfo, 3700.0);
|
||||
query.find({
|
||||
success: function(results) {
|
||||
@@ -246,8 +246,8 @@ describe('Parse.GeoPoint testing', () => {
|
||||
|
||||
it('geo max distance in km bay area', (done) => {
|
||||
makeSomeGeoPoints(function() {
|
||||
var sfo = new Parse.GeoPoint(37.6189722, -122.3748889);
|
||||
var query = new Parse.Query(TestObject);
|
||||
const sfo = new Parse.GeoPoint(37.6189722, -122.3748889);
|
||||
const query = new Parse.Query(TestObject);
|
||||
query.withinKilometers('location', sfo, 100.0);
|
||||
query.find({
|
||||
success: function(results) {
|
||||
@@ -261,8 +261,8 @@ describe('Parse.GeoPoint testing', () => {
|
||||
|
||||
it('geo max distance in km mid peninsula', (done) => {
|
||||
makeSomeGeoPoints(function() {
|
||||
var sfo = new Parse.GeoPoint(37.6189722, -122.3748889);
|
||||
var query = new Parse.Query(TestObject);
|
||||
const sfo = new Parse.GeoPoint(37.6189722, -122.3748889);
|
||||
const query = new Parse.Query(TestObject);
|
||||
query.withinKilometers('location', sfo, 10.0);
|
||||
query.find({
|
||||
success: function(results) {
|
||||
@@ -275,8 +275,8 @@ describe('Parse.GeoPoint testing', () => {
|
||||
|
||||
it('geo max distance in miles everywhere', (done) => {
|
||||
makeSomeGeoPoints(function() {
|
||||
var sfo = new Parse.GeoPoint(37.6189722, -122.3748889);
|
||||
var query = new Parse.Query(TestObject);
|
||||
const sfo = new Parse.GeoPoint(37.6189722, -122.3748889);
|
||||
const query = new Parse.Query(TestObject);
|
||||
query.withinMiles('location', sfo, 2600.0);
|
||||
query.find({
|
||||
success: function(results) {
|
||||
@@ -289,8 +289,8 @@ describe('Parse.GeoPoint testing', () => {
|
||||
|
||||
it('geo max distance in miles california', (done) => {
|
||||
makeSomeGeoPoints(function() {
|
||||
var sfo = new Parse.GeoPoint(37.6189722, -122.3748889);
|
||||
var query = new Parse.Query(TestObject);
|
||||
const sfo = new Parse.GeoPoint(37.6189722, -122.3748889);
|
||||
const query = new Parse.Query(TestObject);
|
||||
query.withinMiles('location', sfo, 2200.0);
|
||||
query.find({
|
||||
success: function(results) {
|
||||
@@ -305,8 +305,8 @@ describe('Parse.GeoPoint testing', () => {
|
||||
|
||||
it('geo max distance in miles bay area', (done) => {
|
||||
makeSomeGeoPoints(function() {
|
||||
var sfo = new Parse.GeoPoint(37.6189722, -122.3748889);
|
||||
var query = new Parse.Query(TestObject);
|
||||
const sfo = new Parse.GeoPoint(37.6189722, -122.3748889);
|
||||
const query = new Parse.Query(TestObject);
|
||||
// 100km is 62 miles...
|
||||
query.withinMiles('location', sfo, 62.0);
|
||||
query.find({
|
||||
@@ -321,8 +321,8 @@ describe('Parse.GeoPoint testing', () => {
|
||||
|
||||
it('geo max distance in miles mid peninsula', (done) => {
|
||||
makeSomeGeoPoints(function() {
|
||||
var sfo = new Parse.GeoPoint(37.6189722, -122.3748889);
|
||||
var query = new Parse.Query(TestObject);
|
||||
const sfo = new Parse.GeoPoint(37.6189722, -122.3748889);
|
||||
const query = new Parse.Query(TestObject);
|
||||
query.withinMiles('location', sfo, 10.0);
|
||||
query.find({
|
||||
success: function(results) {
|
||||
@@ -335,8 +335,8 @@ describe('Parse.GeoPoint testing', () => {
|
||||
|
||||
it('returns nearest location', (done) => {
|
||||
makeSomeGeoPoints(function() {
|
||||
var sfo = new Parse.GeoPoint(37.6189722, -122.3748889);
|
||||
var query = new Parse.Query(TestObject);
|
||||
const sfo = new Parse.GeoPoint(37.6189722, -122.3748889);
|
||||
const query = new Parse.Query(TestObject);
|
||||
query.near('location', sfo);
|
||||
query.find({
|
||||
success: function(results) {
|
||||
@@ -368,16 +368,16 @@ describe('Parse.GeoPoint testing', () => {
|
||||
});
|
||||
|
||||
it('supports a sub-object with a geo point', done => {
|
||||
var point = new Parse.GeoPoint(44.0, -11.0);
|
||||
var obj = new TestObject();
|
||||
const point = new Parse.GeoPoint(44.0, -11.0);
|
||||
const obj = new TestObject();
|
||||
obj.set('subobject', { location: point });
|
||||
obj.save(null, {
|
||||
success: function() {
|
||||
var query = new Parse.Query(TestObject);
|
||||
const query = new Parse.Query(TestObject);
|
||||
query.find({
|
||||
success: function(results) {
|
||||
equal(results.length, 1);
|
||||
var pointAgain = results[0].get('subobject')['location'];
|
||||
const pointAgain = results[0].get('subobject')['location'];
|
||||
ok(pointAgain);
|
||||
equal(pointAgain.latitude, 44.0);
|
||||
equal(pointAgain.longitude, -11.0);
|
||||
@@ -389,17 +389,17 @@ describe('Parse.GeoPoint testing', () => {
|
||||
});
|
||||
|
||||
it('supports array of geo points', done => {
|
||||
var point1 = new Parse.GeoPoint(44.0, -11.0);
|
||||
var point2 = new Parse.GeoPoint(22.0, -55.0);
|
||||
var obj = new TestObject();
|
||||
const point1 = new Parse.GeoPoint(44.0, -11.0);
|
||||
const point2 = new Parse.GeoPoint(22.0, -55.0);
|
||||
const obj = new TestObject();
|
||||
obj.set('locations', [ point1, point2 ]);
|
||||
obj.save(null, {
|
||||
success: function() {
|
||||
var query = new Parse.Query(TestObject);
|
||||
const query = new Parse.Query(TestObject);
|
||||
query.find({
|
||||
success: function(results) {
|
||||
equal(results.length, 1);
|
||||
var locations = results[0].get('locations');
|
||||
const locations = results[0].get('locations');
|
||||
expect(locations.length).toEqual(2);
|
||||
expect(locations[0]).toEqual(point1);
|
||||
expect(locations[1]).toEqual(point2);
|
||||
@@ -411,8 +411,8 @@ describe('Parse.GeoPoint testing', () => {
|
||||
});
|
||||
|
||||
it('equalTo geopoint', (done) => {
|
||||
var point = new Parse.GeoPoint(44.0, -11.0);
|
||||
var obj = new TestObject();
|
||||
const point = new Parse.GeoPoint(44.0, -11.0);
|
||||
const obj = new TestObject();
|
||||
obj.set('location', point);
|
||||
obj.save().then(() => {
|
||||
const query = new Parse.Query(TestObject);
|
||||
|
||||
Reference in New Issue
Block a user