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,24 +2,24 @@
|
||||
// It would probably be better to refactor them into different files.
|
||||
'use strict';
|
||||
|
||||
var request = require('request');
|
||||
const request = require('request');
|
||||
const rp = require('request-promise');
|
||||
const Parse = require("parse/node");
|
||||
const Config = require('../src/Config');
|
||||
const SchemaController = require('../src/Controllers/SchemaController');
|
||||
var TestUtils = require('../src/TestUtils');
|
||||
const TestUtils = require('../src/TestUtils');
|
||||
|
||||
const userSchema = SchemaController.convertSchemaToAdapterSchema({ className: '_User', fields: Object.assign({}, SchemaController.defaultColumns._Default, SchemaController.defaultColumns._User) });
|
||||
|
||||
describe_only_db('mongo')('miscellaneous', () => {
|
||||
it('test rest_create_app', function(done) {
|
||||
var appId;
|
||||
let appId;
|
||||
Parse._request('POST', 'rest_create_app').then((res) => {
|
||||
expect(typeof res.application_id).toEqual('string');
|
||||
expect(res.master_key).toEqual('master');
|
||||
appId = res.application_id;
|
||||
Parse.initialize(appId, 'unused');
|
||||
var obj = new Parse.Object('TestObject');
|
||||
const obj = new Parse.Object('TestObject');
|
||||
obj.set('foo', 'bar');
|
||||
return obj.save();
|
||||
}).then(() => {
|
||||
@@ -38,7 +38,7 @@ describe_only_db('mongo')('miscellaneous', () => {
|
||||
|
||||
describe('miscellaneous', function() {
|
||||
it('create a GameScore object', function(done) {
|
||||
var obj = new Parse.Object('GameScore');
|
||||
const obj = new Parse.Object('GameScore');
|
||||
obj.set('score', 1337);
|
||||
obj.save().then(function(obj) {
|
||||
expect(typeof obj.id).toBe('string');
|
||||
@@ -52,7 +52,7 @@ describe('miscellaneous', function() {
|
||||
|
||||
it('get a TestObject', function(done) {
|
||||
create({ 'bloop' : 'blarg' }, function(obj) {
|
||||
var t2 = new TestObject({ objectId: obj.id });
|
||||
const t2 = new TestObject({ objectId: obj.id });
|
||||
t2.fetch({
|
||||
success: function(obj2) {
|
||||
expect(obj2.get('bloop')).toEqual('blarg');
|
||||
@@ -277,12 +277,12 @@ describe('miscellaneous', function() {
|
||||
});
|
||||
|
||||
it('save various data types', function(done) {
|
||||
var obj = new TestObject();
|
||||
const obj = new TestObject();
|
||||
obj.set('date', new Date());
|
||||
obj.set('array', [1, 2, 3]);
|
||||
obj.set('object', {one: 1, two: 2});
|
||||
obj.save().then(() => {
|
||||
var obj2 = new TestObject({objectId: obj.id});
|
||||
const obj2 = new TestObject({objectId: obj.id});
|
||||
return obj2.fetch();
|
||||
}).then((obj2) => {
|
||||
expect(obj2.get('date') instanceof Date).toBe(true);
|
||||
@@ -294,12 +294,12 @@ describe('miscellaneous', function() {
|
||||
});
|
||||
|
||||
it('query with limit', function(done) {
|
||||
var baz = new TestObject({ foo: 'baz' });
|
||||
var qux = new TestObject({ foo: 'qux' });
|
||||
const baz = new TestObject({ foo: 'baz' });
|
||||
const qux = new TestObject({ foo: 'qux' });
|
||||
baz.save().then(() => {
|
||||
return qux.save();
|
||||
}).then(() => {
|
||||
var query = new Parse.Query(TestObject);
|
||||
const query = new Parse.Query(TestObject);
|
||||
query.limit(1);
|
||||
return query.find();
|
||||
}).then((results) => {
|
||||
@@ -312,8 +312,8 @@ describe('miscellaneous', function() {
|
||||
});
|
||||
|
||||
it('query without limit get default 100 records', function(done) {
|
||||
var objects = [];
|
||||
for (var i = 0; i < 150; i++) {
|
||||
const objects = [];
|
||||
for (let i = 0; i < 150; i++) {
|
||||
objects.push(new TestObject({name: 'name' + i}));
|
||||
}
|
||||
Parse.Object.saveAll(objects).then(() => {
|
||||
@@ -328,8 +328,8 @@ describe('miscellaneous', function() {
|
||||
});
|
||||
|
||||
it('basic saveAll', function(done) {
|
||||
var alpha = new TestObject({ letter: 'alpha' });
|
||||
var beta = new TestObject({ letter: 'beta' });
|
||||
const alpha = new TestObject({ letter: 'alpha' });
|
||||
const beta = new TestObject({ letter: 'beta' });
|
||||
Parse.Object.saveAll([alpha, beta]).then(() => {
|
||||
expect(alpha.id).toBeTruthy();
|
||||
expect(beta.id).toBeTruthy();
|
||||
@@ -344,7 +344,7 @@ describe('miscellaneous', function() {
|
||||
});
|
||||
|
||||
it('test beforeSave set object acl success', function(done) {
|
||||
var acl = new Parse.ACL({
|
||||
const acl = new Parse.ACL({
|
||||
'*': { read: true, write: false }
|
||||
});
|
||||
Parse.Cloud.beforeSave('BeforeSaveAddACL', function(req, res) {
|
||||
@@ -352,10 +352,10 @@ describe('miscellaneous', function() {
|
||||
res.success();
|
||||
});
|
||||
|
||||
var obj = new Parse.Object('BeforeSaveAddACL');
|
||||
const obj = new Parse.Object('BeforeSaveAddACL');
|
||||
obj.set('lol', true);
|
||||
obj.save().then(function() {
|
||||
var query = new Parse.Query('BeforeSaveAddACL');
|
||||
const query = new Parse.Query('BeforeSaveAddACL');
|
||||
query.get(obj.id).then(function(objAgain) {
|
||||
expect(objAgain.get('lol')).toBeTruthy();
|
||||
expect(objAgain.getACL().equals(acl));
|
||||
@@ -534,20 +534,20 @@ describe('miscellaneous', function() {
|
||||
it('pointer reassign is working properly (#1288)', (done) => {
|
||||
Parse.Cloud.beforeSave('GameScore', (req, res) => {
|
||||
|
||||
var obj = req.object;
|
||||
const obj = req.object;
|
||||
if (obj.get('point')) {
|
||||
return res.success();
|
||||
}
|
||||
var TestObject1 = Parse.Object.extend('TestObject1');
|
||||
var newObj = new TestObject1({'key1': 1});
|
||||
const TestObject1 = Parse.Object.extend('TestObject1');
|
||||
const newObj = new TestObject1({'key1': 1});
|
||||
|
||||
return newObj.save().then((newObj) => {
|
||||
obj.set('point' , newObj);
|
||||
res.success();
|
||||
});
|
||||
});
|
||||
var pointId;
|
||||
var obj = new Parse.Object('GameScore');
|
||||
let pointId;
|
||||
const obj = new Parse.Object('GameScore');
|
||||
obj.set('foo', 'bar');
|
||||
obj.save().then(() => {
|
||||
expect(obj.get('point')).not.toBeUndefined();
|
||||
@@ -562,10 +562,10 @@ describe('miscellaneous', function() {
|
||||
});
|
||||
|
||||
it('test afterSave get full object on create and update', function(done) {
|
||||
var triggerTime = 0;
|
||||
let triggerTime = 0;
|
||||
// Register a mock beforeSave hook
|
||||
Parse.Cloud.afterSave('GameScore', function(req, res) {
|
||||
var object = req.object;
|
||||
const object = req.object;
|
||||
expect(object instanceof Parse.Object).toBeTruthy();
|
||||
expect(object.id).not.toBeUndefined();
|
||||
expect(object.createdAt).not.toBeUndefined();
|
||||
@@ -584,7 +584,7 @@ describe('miscellaneous', function() {
|
||||
res.success();
|
||||
});
|
||||
|
||||
var obj = new Parse.Object('GameScore');
|
||||
const obj = new Parse.Object('GameScore');
|
||||
obj.set('foo', 'bar');
|
||||
obj.set('fooAgain', 'barAgain');
|
||||
obj.save().then(function() {
|
||||
@@ -602,17 +602,17 @@ describe('miscellaneous', function() {
|
||||
});
|
||||
|
||||
it('test afterSave get original object on update', function(done) {
|
||||
var triggerTime = 0;
|
||||
let triggerTime = 0;
|
||||
// Register a mock beforeSave hook
|
||||
|
||||
Parse.Cloud.afterSave('GameScore', function(req, res) {
|
||||
var object = req.object;
|
||||
const object = req.object;
|
||||
expect(object instanceof Parse.Object).toBeTruthy();
|
||||
expect(object.get('fooAgain')).toEqual('barAgain');
|
||||
expect(object.id).not.toBeUndefined();
|
||||
expect(object.createdAt).not.toBeUndefined();
|
||||
expect(object.updatedAt).not.toBeUndefined();
|
||||
var originalObject = req.original;
|
||||
const originalObject = req.original;
|
||||
if (triggerTime == 0) {
|
||||
// Create
|
||||
expect(object.get('foo')).toEqual('bar');
|
||||
@@ -635,7 +635,7 @@ describe('miscellaneous', function() {
|
||||
res.success();
|
||||
});
|
||||
|
||||
var obj = new Parse.Object('GameScore');
|
||||
const obj = new Parse.Object('GameScore');
|
||||
obj.set('foo', 'bar');
|
||||
obj.set('fooAgain', 'barAgain');
|
||||
obj.save().then(function() {
|
||||
@@ -653,11 +653,11 @@ describe('miscellaneous', function() {
|
||||
});
|
||||
|
||||
it('test afterSave get full original object even req auth can not query it', (done) => {
|
||||
var triggerTime = 0;
|
||||
let triggerTime = 0;
|
||||
// Register a mock beforeSave hook
|
||||
Parse.Cloud.afterSave('GameScore', function(req, res) {
|
||||
var object = req.object;
|
||||
var originalObject = req.original;
|
||||
const object = req.object;
|
||||
const originalObject = req.original;
|
||||
if (triggerTime == 0) {
|
||||
// Create
|
||||
} else if (triggerTime == 1) {
|
||||
@@ -677,10 +677,10 @@ describe('miscellaneous', function() {
|
||||
res.success();
|
||||
});
|
||||
|
||||
var obj = new Parse.Object('GameScore');
|
||||
const obj = new Parse.Object('GameScore');
|
||||
obj.set('foo', 'bar');
|
||||
obj.set('fooAgain', 'barAgain');
|
||||
var acl = new Parse.ACL();
|
||||
const acl = new Parse.ACL();
|
||||
// Make sure our update request can not query the object
|
||||
acl.setPublicReadAccess(false);
|
||||
acl.setPublicWriteAccess(true);
|
||||
@@ -700,7 +700,7 @@ describe('miscellaneous', function() {
|
||||
});
|
||||
|
||||
it('afterSave flattens custom operations', done => {
|
||||
var triggerTime = 0;
|
||||
let triggerTime = 0;
|
||||
// Register a mock beforeSave hook
|
||||
Parse.Cloud.afterSave('GameScore', function(req, res) {
|
||||
const object = req.object;
|
||||
@@ -721,7 +721,7 @@ describe('miscellaneous', function() {
|
||||
res.success();
|
||||
});
|
||||
|
||||
var obj = new Parse.Object('GameScore');
|
||||
const obj = new Parse.Object('GameScore');
|
||||
obj.increment('yolo', 1);
|
||||
obj.save().then(() => {
|
||||
obj.increment('yolo', 1);
|
||||
@@ -817,7 +817,7 @@ describe('miscellaneous', function() {
|
||||
it('should return the updated fields on PUT', done => {
|
||||
const obj = new Parse.Object('GameScore');
|
||||
obj.save({a:'hello', c: 1, d: ['1'], e:['1'], f:['1','2']}).then(() => {
|
||||
var headers = {
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Parse-Application-Id': 'test',
|
||||
'X-Parse-REST-API-Key': 'rest',
|
||||
@@ -921,7 +921,7 @@ describe('miscellaneous', function() {
|
||||
expect(req.installationId).toEqual('yolo');
|
||||
});
|
||||
|
||||
var headers = {
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Parse-Application-Id': 'test',
|
||||
'X-Parse-REST-API-Key': 'rest',
|
||||
@@ -952,7 +952,7 @@ describe('miscellaneous', function() {
|
||||
expect(req.installationId).toEqual('yolo');
|
||||
});
|
||||
|
||||
var headers = {
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Parse-Application-Id': 'test',
|
||||
'X-Parse-REST-API-Key': 'rest',
|
||||
@@ -979,7 +979,7 @@ describe('miscellaneous', function() {
|
||||
Parse.Cloud.define('echoParams', (req, res) => {
|
||||
res.success(req.params);
|
||||
});
|
||||
var headers = {
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Parse-Application-Id': 'test',
|
||||
'X-Parse-Javascript-Key': 'test'
|
||||
@@ -994,7 +994,7 @@ describe('miscellaneous', function() {
|
||||
body: '{"foo":"bar", "other": 1}'
|
||||
}, (error, response, body) => {
|
||||
expect(error).toBe(null);
|
||||
var res = JSON.parse(body).result;
|
||||
const res = JSON.parse(body).result;
|
||||
expect(res.option).toEqual('1');
|
||||
// Make sure query string params override body params
|
||||
expect(res.other).toEqual('2');
|
||||
@@ -1054,7 +1054,7 @@ describe('miscellaneous', function() {
|
||||
});
|
||||
|
||||
it('fails on invalid client key', done => {
|
||||
var headers = {
|
||||
const headers = {
|
||||
'Content-Type': 'application/octet-stream',
|
||||
'X-Parse-Application-Id': 'test',
|
||||
'X-Parse-Client-Key': 'notclient'
|
||||
@@ -1064,14 +1064,14 @@ describe('miscellaneous', function() {
|
||||
url: 'http://localhost:8378/1/classes/TestObject'
|
||||
}, (error, response, body) => {
|
||||
expect(error).toBe(null);
|
||||
var b = JSON.parse(body);
|
||||
const b = JSON.parse(body);
|
||||
expect(b.error).toEqual('unauthorized');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('fails on invalid windows key', done => {
|
||||
var headers = {
|
||||
const headers = {
|
||||
'Content-Type': 'application/octet-stream',
|
||||
'X-Parse-Application-Id': 'test',
|
||||
'X-Parse-Windows-Key': 'notwindows'
|
||||
@@ -1081,14 +1081,14 @@ describe('miscellaneous', function() {
|
||||
url: 'http://localhost:8378/1/classes/TestObject'
|
||||
}, (error, response, body) => {
|
||||
expect(error).toBe(null);
|
||||
var b = JSON.parse(body);
|
||||
const b = JSON.parse(body);
|
||||
expect(b.error).toEqual('unauthorized');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('fails on invalid javascript key', done => {
|
||||
var headers = {
|
||||
const headers = {
|
||||
'Content-Type': 'application/octet-stream',
|
||||
'X-Parse-Application-Id': 'test',
|
||||
'X-Parse-Javascript-Key': 'notjavascript'
|
||||
@@ -1098,14 +1098,14 @@ describe('miscellaneous', function() {
|
||||
url: 'http://localhost:8378/1/classes/TestObject'
|
||||
}, (error, response, body) => {
|
||||
expect(error).toBe(null);
|
||||
var b = JSON.parse(body);
|
||||
const b = JSON.parse(body);
|
||||
expect(b.error).toEqual('unauthorized');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('fails on invalid rest api key', done => {
|
||||
var headers = {
|
||||
const headers = {
|
||||
'Content-Type': 'application/octet-stream',
|
||||
'X-Parse-Application-Id': 'test',
|
||||
'X-Parse-REST-API-Key': 'notrest'
|
||||
@@ -1115,7 +1115,7 @@ describe('miscellaneous', function() {
|
||||
url: 'http://localhost:8378/1/classes/TestObject'
|
||||
}, (error, response, body) => {
|
||||
expect(error).toBe(null);
|
||||
var b = JSON.parse(body);
|
||||
const b = JSON.parse(body);
|
||||
expect(b.error).toEqual('unauthorized');
|
||||
done();
|
||||
});
|
||||
@@ -1442,7 +1442,7 @@ describe('miscellaneous', function() {
|
||||
'X-Parse-Application-Id': 'test',
|
||||
'X-Parse-Master-Key': 'test'
|
||||
};
|
||||
var user, object;
|
||||
let user, object;
|
||||
createTestUser().then((x) => {
|
||||
user = x;
|
||||
const acl = new Parse.ACL();
|
||||
|
||||
Reference in New Issue
Block a user