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:
Florent Vilmart
2018-02-17 09:55:30 -05:00
committed by GitHub
parent 8ec7785d53
commit b754d51e8e
81 changed files with 2698 additions and 2704 deletions

View File

@@ -3,18 +3,18 @@
"use strict";
var request = require('request');
const request = require('request');
var str = "Hello World!";
var data = [];
for (var i = 0; i < str.length; i++) {
const str = "Hello World!";
const data = [];
for (let i = 0; i < str.length; i++) {
data.push(str.charCodeAt(i));
}
describe('Parse.File testing', () => {
describe('creating files', () => {
it('works with Content-Type', done => {
var headers = {
const headers = {
'Content-Type': 'application/octet-stream',
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest'
@@ -25,7 +25,7 @@ describe('Parse.File testing', () => {
body: 'argle bargle',
}, (error, response, body) => {
expect(error).toBe(null);
var b = JSON.parse(body);
const b = JSON.parse(body);
expect(b.name).toMatch(/_file.txt$/);
expect(b.url).toMatch(/^http:\/\/localhost:8378\/1\/files\/test\/.*file.txt$/);
request.get(b.url, (error, response, body) => {
@@ -49,7 +49,7 @@ describe('Parse.File testing', () => {
})
}, (error, response, body) => {
expect(error).toBe(null);
var b = JSON.parse(body);
const b = JSON.parse(body);
expect(b.name).toMatch(/_file.html/);
expect(b.url).toMatch(/^http:\/\/localhost:8378\/1\/files\/test\/.*file.html$/);
request.get(b.url, (error, response, body) => {
@@ -66,7 +66,7 @@ describe('Parse.File testing', () => {
});
it('works without Content-Type', done => {
var headers = {
const headers = {
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest'
};
@@ -76,7 +76,7 @@ describe('Parse.File testing', () => {
body: 'argle bargle',
}, (error, response, body) => {
expect(error).toBe(null);
var b = JSON.parse(body);
const b = JSON.parse(body);
expect(b.name).toMatch(/_file.txt$/);
expect(b.url).toMatch(/^http:\/\/localhost:8378\/1\/files\/test\/.*file.txt$/);
request.get(b.url, (error, response, body) => {
@@ -89,7 +89,7 @@ describe('Parse.File testing', () => {
});
it('supports REST end-to-end file create, read, delete, read', done => {
var headers = {
const headers = {
'Content-Type': 'image/jpeg',
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest'
@@ -100,7 +100,7 @@ describe('Parse.File testing', () => {
body: 'check one two',
}, (error, response, body) => {
expect(error).toBe(null);
var b = JSON.parse(body);
const b = JSON.parse(body);
expect(b.name).toMatch(/_testfile.txt$/);
expect(b.url).toMatch(/^http:\/\/localhost:8378\/1\/files\/test\/.*testfile.txt$/);
request.get(b.url, (error, response, body) => {
@@ -137,7 +137,7 @@ describe('Parse.File testing', () => {
});
it('blocks file deletions with missing or incorrect master-key header', done => {
var headers = {
const headers = {
'Content-Type': 'image/jpeg',
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest'
@@ -148,7 +148,7 @@ describe('Parse.File testing', () => {
body: 'the file body'
}, (error, response, body) => {
expect(error).toBe(null);
var b = JSON.parse(body);
const b = JSON.parse(body);
expect(b.url).toMatch(/^http:\/\/localhost:8378\/1\/files\/test\/.*thefile.jpg$/);
// missing X-Parse-Master-Key header
request.del({
@@ -159,7 +159,7 @@ describe('Parse.File testing', () => {
url: 'http://localhost:8378/1/files/' + b.name
}, (error, response, body) => {
expect(error).toBe(null);
var del_b = JSON.parse(body);
const del_b = JSON.parse(body);
expect(response.statusCode).toEqual(403);
expect(del_b.error).toMatch(/unauthorized/);
// incorrect X-Parse-Master-Key header
@@ -172,7 +172,7 @@ describe('Parse.File testing', () => {
url: 'http://localhost:8378/1/files/' + b.name
}, (error, response, body) => {
expect(error).toBe(null);
var del_b2 = JSON.parse(body);
const del_b2 = JSON.parse(body);
expect(response.statusCode).toEqual(403);
expect(del_b2.error).toMatch(/unauthorized/);
done();
@@ -182,7 +182,7 @@ describe('Parse.File testing', () => {
});
it('handles other filetypes', done => {
var headers = {
const headers = {
'Content-Type': 'image/jpeg',
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest'
@@ -193,7 +193,7 @@ describe('Parse.File testing', () => {
body: 'argle bargle',
}, (error, response, body) => {
expect(error).toBe(null);
var b = JSON.parse(body);
const b = JSON.parse(body);
expect(b.name).toMatch(/_file.jpg$/);
expect(b.url).toMatch(/^http:\/\/localhost:8378\/1\/files\/.*file.jpg$/);
request.get(b.url, (error, response, body) => {
@@ -205,7 +205,7 @@ describe('Parse.File testing', () => {
});
it("save file", done => {
var file = new Parse.File("hello.txt", data, "text/plain");
const file = new Parse.File("hello.txt", data, "text/plain");
ok(!file.url());
file.save(expectSuccess({
success: function(result) {
@@ -219,7 +219,7 @@ describe('Parse.File testing', () => {
});
it("save file in object", done => {
var file = new Parse.File("hello.txt", data, "text/plain");
const file = new Parse.File("hello.txt", data, "text/plain");
ok(!file.url());
file.save(expectSuccess({
success: function(result) {
@@ -228,7 +228,7 @@ describe('Parse.File testing', () => {
ok(file.url());
notEqual(file.name(), "hello.txt");
var object = new Parse.Object("TestObject");
const object = new Parse.Object("TestObject");
object.save({
file: file
}, expectSuccess({
@@ -246,7 +246,7 @@ describe('Parse.File testing', () => {
});
it("save file in object with escaped characters in filename", done => {
var file = new Parse.File("hello . txt", data, "text/plain");
const file = new Parse.File("hello . txt", data, "text/plain");
ok(!file.url());
file.save(expectSuccess({
success: function(result) {
@@ -255,7 +255,7 @@ describe('Parse.File testing', () => {
ok(file.url());
notEqual(file.name(), "hello . txt");
var object = new Parse.Object("TestObject");
const object = new Parse.Object("TestObject");
object.save({
file: file
}, expectSuccess({
@@ -274,9 +274,9 @@ describe('Parse.File testing', () => {
});
it("autosave file in object", done => {
var file = new Parse.File("hello.txt", data, "text/plain");
let file = new Parse.File("hello.txt", data, "text/plain");
ok(!file.url());
var object = new Parse.Object("TestObject");
const object = new Parse.Object("TestObject");
object.save({
file: file
}, expectSuccess({
@@ -296,22 +296,22 @@ describe('Parse.File testing', () => {
});
it("autosave file in object in object", done => {
var file = new Parse.File("hello.txt", data, "text/plain");
let file = new Parse.File("hello.txt", data, "text/plain");
ok(!file.url());
var child = new Parse.Object("Child");
const child = new Parse.Object("Child");
child.set("file", file);
var parent = new Parse.Object("Parent");
const parent = new Parse.Object("Parent");
parent.set("child", child);
parent.save(expectSuccess({
success: function(parent) {
var query = new Parse.Query("Parent");
const query = new Parse.Query("Parent");
query.include("child");
query.get(parent.id, expectSuccess({
success: function(parentAgain) {
var childAgain = parentAgain.get("child");
const childAgain = parentAgain.get("child");
file = childAgain.get("file");
ok(file instanceof Parse.File);
ok(file.name());
@@ -325,7 +325,7 @@ describe('Parse.File testing', () => {
});
it("saving an already saved file", done => {
var file = new Parse.File("hello.txt", data, "text/plain");
const file = new Parse.File("hello.txt", data, "text/plain");
ok(!file.url());
file.save(expectSuccess({
success: function(result) {
@@ -333,7 +333,7 @@ describe('Parse.File testing', () => {
ok(file.name());
ok(file.url());
notEqual(file.name(), "hello.txt");
var previousName = file.name();
const previousName = file.name();
file.save(expectSuccess({
success: function() {
@@ -346,13 +346,13 @@ describe('Parse.File testing', () => {
});
it("two saves at the same time", done => {
var file = new Parse.File("hello.txt", data, "text/plain");
const file = new Parse.File("hello.txt", data, "text/plain");
var firstName;
var secondName;
let firstName;
let secondName;
var firstSave = file.save().then(function() { firstName = file.name(); });
var secondSave = file.save().then(function() { secondName = file.name(); });
const firstSave = file.save().then(function() { firstName = file.name(); });
const secondSave = file.save().then(function() { secondName = file.name(); });
Parse.Promise.when(firstSave, secondSave).then(function() {
equal(firstName, secondName);
@@ -364,9 +364,9 @@ describe('Parse.File testing', () => {
});
it("file toJSON testing", done => {
var file = new Parse.File("hello.txt", data, "text/plain");
const file = new Parse.File("hello.txt", data, "text/plain");
ok(!file.url());
var object = new Parse.Object("TestObject");
const object = new Parse.Object("TestObject");
object.save({
file: file
}, expectSuccess({
@@ -378,7 +378,7 @@ describe('Parse.File testing', () => {
});
it("content-type used with no extension", done => {
var headers = {
const headers = {
'Content-Type': 'text/html',
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest'
@@ -389,7 +389,7 @@ describe('Parse.File testing', () => {
body: 'fee fi fo',
}, (error, response, body) => {
expect(error).toBe(null);
var b = JSON.parse(body);
const b = JSON.parse(body);
expect(b.name).toMatch(/\.html$/);
request.get(b.url, (error, response) => {
if (!response) {
@@ -403,7 +403,7 @@ describe('Parse.File testing', () => {
});
it("filename is url encoded", done => {
var headers = {
const headers = {
'Content-Type': 'text/html',
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest'
@@ -414,26 +414,26 @@ describe('Parse.File testing', () => {
body: 'oh emm gee',
}, (error, response, body) => {
expect(error).toBe(null);
var b = JSON.parse(body);
const b = JSON.parse(body);
expect(b.url).toMatch(/hello%20world/);
done();
})
});
it('supports array of files', done => {
var file = {
const file = {
__type: 'File',
url: 'http://meep.meep',
name: 'meep'
};
var files = [file, file];
var obj = new Parse.Object('FilesArrayTest');
const files = [file, file];
const obj = new Parse.Object('FilesArrayTest');
obj.set('files', files);
obj.save().then(() => {
var query = new Parse.Query('FilesArrayTest');
const query = new Parse.Query('FilesArrayTest');
return query.first();
}).then((result) => {
var filesAgain = result.get('files');
const filesAgain = result.get('files');
expect(filesAgain.length).toEqual(2);
expect(filesAgain[0].name()).toEqual('meep');
expect(filesAgain[0].url()).toEqual('http://meep.meep');
@@ -442,7 +442,7 @@ describe('Parse.File testing', () => {
});
it('validates filename characters', done => {
var headers = {
const headers = {
'Content-Type': 'text/plain',
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest'
@@ -452,19 +452,19 @@ describe('Parse.File testing', () => {
url: 'http://localhost:8378/1/files/di$avowed.txt',
body: 'will fail',
}, (error, response, body) => {
var b = JSON.parse(body);
const b = JSON.parse(body);
expect(b.code).toEqual(122);
done();
});
});
it('validates filename length', done => {
var headers = {
const headers = {
'Content-Type': 'text/plain',
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest'
};
var fileName = 'Onceuponamidnightdrearywhileiponderedweak' +
const fileName = 'Onceuponamidnightdrearywhileiponderedweak' +
'andwearyOveramanyquaintandcuriousvolumeof' +
'forgottenloreWhileinoddednearlynappingsud' +
'denlytherecameatapping';
@@ -473,30 +473,30 @@ describe('Parse.File testing', () => {
url: 'http://localhost:8378/1/files/' + fileName,
body: 'will fail',
}, (error, response, body) => {
var b = JSON.parse(body);
const b = JSON.parse(body);
expect(b.code).toEqual(122);
done();
});
});
it('supports a dictionary with file', done => {
var file = {
const file = {
__type: 'File',
url: 'http://meep.meep',
name: 'meep'
};
var dict = {
const dict = {
file: file
};
var obj = new Parse.Object('FileObjTest');
const obj = new Parse.Object('FileObjTest');
obj.set('obj', dict);
obj.save().then(() => {
var query = new Parse.Query('FileObjTest');
const query = new Parse.Query('FileObjTest');
return query.first();
}).then((result) => {
var dictAgain = result.get('obj');
const dictAgain = result.get('obj');
expect(typeof dictAgain).toEqual('object');
var fileAgain = dictAgain['file'];
const fileAgain = dictAgain['file'];
expect(fileAgain.name()).toEqual('meep');
expect(fileAgain.url()).toEqual('http://meep.meep');
done();
@@ -507,18 +507,18 @@ describe('Parse.File testing', () => {
});
it('creates correct url for old files hosted on files.parsetfss.com', done => {
var file = {
const file = {
__type: 'File',
url: 'http://irrelevant.elephant/',
name: 'tfss-123.txt'
};
var obj = new Parse.Object('OldFileTest');
const obj = new Parse.Object('OldFileTest');
obj.set('oldfile', file);
obj.save().then(() => {
var query = new Parse.Query('OldFileTest');
const query = new Parse.Query('OldFileTest');
return query.first();
}).then((result) => {
var fileAgain = result.get('oldfile');
const fileAgain = result.get('oldfile');
expect(fileAgain.url()).toEqual(
'http://files.parsetfss.com/test/tfss-123.txt'
);
@@ -530,18 +530,18 @@ describe('Parse.File testing', () => {
});
it('creates correct url for old files hosted on files.parse.com', done => {
var file = {
const file = {
__type: 'File',
url: 'http://irrelevant.elephant/',
name: 'd6e80979-a128-4c57-a167-302f874700dc-123.txt'
};
var obj = new Parse.Object('OldFileTest');
const obj = new Parse.Object('OldFileTest');
obj.set('oldfile', file);
obj.save().then(() => {
var query = new Parse.Query('OldFileTest');
const query = new Parse.Query('OldFileTest');
return query.first();
}).then((result) => {
var fileAgain = result.get('oldfile');
const fileAgain = result.get('oldfile');
expect(fileAgain.url()).toEqual(
'http://files.parse.com/test/d6e80979-a128-4c57-a167-302f874700dc-123.txt'
);
@@ -553,14 +553,14 @@ describe('Parse.File testing', () => {
});
it('supports files in objects without urls', done => {
var file = {
const file = {
__type: 'File',
name: '123.txt'
};
var obj = new Parse.Object('FileTest');
const obj = new Parse.Object('FileTest');
obj.set('file', file);
obj.save().then(() => {
var query = new Parse.Query('FileTest');
const query = new Parse.Query('FileTest');
return query.first();
}).then(result => {
const fileAgain = result.get('file');
@@ -576,15 +576,15 @@ describe('Parse.File testing', () => {
reconfigureServer({
publicServerURL: 'https://mydomain/parse'
}).then(() => {
var file = {
const file = {
__type: 'File',
name: '123.txt'
};
var obj = new Parse.Object('FileTest');
const obj = new Parse.Object('FileTest');
obj.set('file', file);
return obj.save()
}).then(() => {
var query = new Parse.Query('FileTest');
const query = new Parse.Query('FileTest');
return query.first();
}).then(result => {
const fileAgain = result.get('file');
@@ -597,7 +597,7 @@ describe('Parse.File testing', () => {
});
it('fails to upload an empty file', done => {
var headers = {
const headers = {
'Content-Type': 'application/octet-stream',
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest'
@@ -615,7 +615,7 @@ describe('Parse.File testing', () => {
});
it('fails to upload without a file name', done => {
var headers = {
const headers = {
'Content-Type': 'application/octet-stream',
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest'
@@ -633,7 +633,7 @@ describe('Parse.File testing', () => {
});
it('fails to upload without a file name', done => {
var headers = {
const headers = {
'Content-Type': 'application/octet-stream',
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest'
@@ -651,7 +651,7 @@ describe('Parse.File testing', () => {
});
it('fails to delete an unkown file', done => {
var headers = {
const headers = {
'Content-Type': 'application/octet-stream',
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest',
@@ -670,7 +670,7 @@ describe('Parse.File testing', () => {
describe_only_db('mongo')('Gridstore Range tests', () => {
it('supports range requests', done => {
var headers = {
const headers = {
'Content-Type': 'application/octet-stream',
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest'
@@ -681,7 +681,7 @@ describe('Parse.File testing', () => {
body: 'argle bargle',
}, (error, response, body) => {
expect(error).toBe(null);
var b = JSON.parse(body);
const b = JSON.parse(body);
request.get({ url: b.url, headers: {
'Content-Type': 'application/octet-stream',
'X-Parse-Application-Id': 'test',
@@ -696,7 +696,7 @@ describe('Parse.File testing', () => {
});
it('supports small range requests', done => {
var headers = {
const headers = {
'Content-Type': 'application/octet-stream',
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest'
@@ -707,7 +707,7 @@ describe('Parse.File testing', () => {
body: 'argle bargle',
}, (error, response, body) => {
expect(error).toBe(null);
var b = JSON.parse(body);
const b = JSON.parse(body);
request.get({ url: b.url, headers: {
'Content-Type': 'application/octet-stream',
'X-Parse-Application-Id': 'test',
@@ -723,7 +723,7 @@ describe('Parse.File testing', () => {
// See specs https://www.greenbytes.de/tech/webdav/draft-ietf-httpbis-p5-range-latest.html#byte.ranges
it('supports getting one byte', done => {
var headers = {
const headers = {
'Content-Type': 'application/octet-stream',
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest'
@@ -734,7 +734,7 @@ describe('Parse.File testing', () => {
body: 'argle bargle',
}, (error, response, body) => {
expect(error).toBe(null);
var b = JSON.parse(body);
const b = JSON.parse(body);
request.get({ url: b.url, headers: {
'Content-Type': 'application/octet-stream',
'X-Parse-Application-Id': 'test',
@@ -749,7 +749,7 @@ describe('Parse.File testing', () => {
});
it('supports getting last n bytes', done => {
var headers = {
const headers = {
'Content-Type': 'application/octet-stream',
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest'
@@ -760,7 +760,7 @@ describe('Parse.File testing', () => {
body: 'something different',
}, (error, response, body) => {
expect(error).toBe(null);
var b = JSON.parse(body);
const b = JSON.parse(body);
request.get({ url: b.url, headers: {
'Content-Type': 'application/octet-stream',
'X-Parse-Application-Id': 'test',
@@ -776,7 +776,7 @@ describe('Parse.File testing', () => {
});
it('supports getting first n bytes', done => {
var headers = {
const headers = {
'Content-Type': 'application/octet-stream',
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest'
@@ -787,7 +787,7 @@ describe('Parse.File testing', () => {
body: 'something different',
}, (error, response, body) => {
expect(error).toBe(null);
var b = JSON.parse(body);
const b = JSON.parse(body);
request.get({ url: b.url, headers: {
'Content-Type': 'application/octet-stream',
'X-Parse-Application-Id': 'test',
@@ -802,7 +802,7 @@ describe('Parse.File testing', () => {
});
function repeat(string, count) {
var s = string;
let s = string;
while (count > 0) {
s += string;
count--;
@@ -811,7 +811,7 @@ describe('Parse.File testing', () => {
}
it('supports large range requests', done => {
var headers = {
const headers = {
'Content-Type': 'application/octet-stream',
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest'
@@ -822,7 +822,7 @@ describe('Parse.File testing', () => {
body: repeat('argle bargle', 100)
}, (error, response, body) => {
expect(error).toBe(null);
var b = JSON.parse(body);
const b = JSON.parse(body);
request.get({ url: b.url, headers: {
'Content-Type': 'application/octet-stream',
'X-Parse-Application-Id': 'test',
@@ -856,7 +856,7 @@ describe('Parse.File testing', () => {
// for fallback tests
describe_only_db('postgres')('Default Range tests', () => {
it('fallback to regular request', done => {
var headers = {
const headers = {
'Content-Type': 'application/octet-stream',
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest'
@@ -867,7 +867,7 @@ describe('Parse.File testing', () => {
body: 'argle bargle',
}, (error, response, body) => {
expect(error).toBe(null);
var b = JSON.parse(body);
const b = JSON.parse(body);
request.get({ url: b.url, headers: {
'Content-Type': 'application/octet-stream',
'X-Parse-Application-Id': 'test',