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

@@ -1,10 +1,10 @@
var Client = require('../src/LiveQuery/Client').Client;
var ParseWebSocket = require('../src/LiveQuery/ParseWebSocketServer').ParseWebSocket;
const Client = require('../src/LiveQuery/Client').Client;
const ParseWebSocket = require('../src/LiveQuery/ParseWebSocketServer').ParseWebSocket;
describe('Client', function() {
it('can be initialized', function() {
var parseWebSocket = new ParseWebSocket({});
var client = new Client(1, parseWebSocket);
const parseWebSocket = new ParseWebSocket({});
const client = new Client(1, parseWebSocket);
expect(client.id).toBe(1);
expect(client.parseWebSocket).toBe(parseWebSocket);
@@ -12,7 +12,7 @@ describe('Client', function() {
});
it('can push response', function() {
var parseWebSocket = {
const parseWebSocket = {
send: jasmine.createSpy('send')
};
Client.pushResponse(parseWebSocket, 'message');
@@ -21,13 +21,13 @@ describe('Client', function() {
});
it('can push error', function() {
var parseWebSocket = {
const parseWebSocket = {
send: jasmine.createSpy('send')
};
Client.pushError(parseWebSocket, 1, 'error', true);
var lastCall = parseWebSocket.send.calls.first();
var messageJSON = JSON.parse(lastCall.args[0]);
const lastCall = parseWebSocket.send.calls.first();
const messageJSON = JSON.parse(lastCall.args[0]);
expect(messageJSON.op).toBe('error');
expect(messageJSON.error).toBe('error');
expect(messageJSON.code).toBe(1);
@@ -35,13 +35,13 @@ describe('Client', function() {
});
it('can add subscription information', function() {
var subscription = {};
var fields = ['test'];
var subscriptionInfo = {
const subscription = {};
const fields = ['test'];
const subscriptionInfo = {
subscription: subscription,
fields: fields
}
var client = new Client(1, {});
const client = new Client(1, {});
client.addSubscriptionInfo(1, subscriptionInfo);
expect(client.subscriptionInfos.size).toBe(1);
@@ -49,27 +49,27 @@ describe('Client', function() {
});
it('can get subscription information', function() {
var subscription = {};
var fields = ['test'];
var subscriptionInfo = {
const subscription = {};
const fields = ['test'];
const subscriptionInfo = {
subscription: subscription,
fields: fields
}
var client = new Client(1, {});
const client = new Client(1, {});
client.addSubscriptionInfo(1, subscriptionInfo);
var subscriptionInfoAgain = client.getSubscriptionInfo(1);
const subscriptionInfoAgain = client.getSubscriptionInfo(1);
expect(subscriptionInfoAgain).toBe(subscriptionInfo);
});
it('can delete subscription information', function() {
var subscription = {};
var fields = ['test'];
var subscriptionInfo = {
const subscription = {};
const fields = ['test'];
const subscriptionInfo = {
subscription: subscription,
fields: fields
}
var client = new Client(1, {});
const client = new Client(1, {});
client.addSubscriptionInfo(1, subscriptionInfo);
client.deleteSubscriptionInfo(1);
@@ -78,7 +78,7 @@ describe('Client', function() {
it('can generate ParseObject JSON with null selected field', function() {
var parseObjectJSON = {
const parseObjectJSON = {
key : 'value',
className: 'test',
objectId: 'test',
@@ -86,13 +86,13 @@ describe('Client', function() {
createdAt: '2015-12-07T21:27:13.746Z',
ACL: 'test',
};
var client = new Client(1, {});
const client = new Client(1, {});
expect(client._toJSONWithFields(parseObjectJSON, null)).toBe(parseObjectJSON);
});
it('can generate ParseObject JSON with undefined selected field', function() {
var parseObjectJSON = {
const parseObjectJSON = {
key : 'value',
className: 'test',
objectId: 'test',
@@ -100,13 +100,13 @@ describe('Client', function() {
createdAt: '2015-12-07T21:27:13.746Z',
ACL: 'test',
};
var client = new Client(1, {});
const client = new Client(1, {});
expect(client._toJSONWithFields(parseObjectJSON, undefined)).toBe(parseObjectJSON);
});
it('can generate ParseObject JSON with selected fields', function() {
var parseObjectJSON = {
const parseObjectJSON = {
key : 'value',
className: 'test',
objectId: 'test',
@@ -115,7 +115,7 @@ describe('Client', function() {
ACL: 'test',
test: 'test'
};
var client = new Client(1, {});
const client = new Client(1, {});
expect(client._toJSONWithFields(parseObjectJSON, ['test'])).toEqual({
className: 'test',
@@ -128,7 +128,7 @@ describe('Client', function() {
});
it('can generate ParseObject JSON with nonexistent selected fields', function() {
var parseObjectJSON = {
const parseObjectJSON = {
key : 'value',
className: 'test',
objectId: 'test',
@@ -137,8 +137,8 @@ describe('Client', function() {
ACL: 'test',
test: 'test'
};
var client = new Client(1, {});
var limitedParseObject = client._toJSONWithFields(parseObjectJSON, ['name']);
const client = new Client(1, {});
const limitedParseObject = client._toJSONWithFields(parseObjectJSON, ['name']);
expect(limitedParseObject).toEqual({
className: 'test',
@@ -151,48 +151,48 @@ describe('Client', function() {
});
it('can push connect response', function() {
var parseWebSocket = {
const parseWebSocket = {
send: jasmine.createSpy('send')
};
var client = new Client(1, parseWebSocket);
const client = new Client(1, parseWebSocket);
client.pushConnect();
var lastCall = parseWebSocket.send.calls.first();
var messageJSON = JSON.parse(lastCall.args[0]);
const lastCall = parseWebSocket.send.calls.first();
const messageJSON = JSON.parse(lastCall.args[0]);
expect(messageJSON.op).toBe('connected');
expect(messageJSON.clientId).toBe(1);
});
it('can push subscribe response', function() {
var parseWebSocket = {
const parseWebSocket = {
send: jasmine.createSpy('send')
};
var client = new Client(1, parseWebSocket);
const client = new Client(1, parseWebSocket);
client.pushSubscribe(2);
var lastCall = parseWebSocket.send.calls.first();
var messageJSON = JSON.parse(lastCall.args[0]);
const lastCall = parseWebSocket.send.calls.first();
const messageJSON = JSON.parse(lastCall.args[0]);
expect(messageJSON.op).toBe('subscribed');
expect(messageJSON.clientId).toBe(1);
expect(messageJSON.requestId).toBe(2);
});
it('can push unsubscribe response', function() {
var parseWebSocket = {
const parseWebSocket = {
send: jasmine.createSpy('send')
};
var client = new Client(1, parseWebSocket);
const client = new Client(1, parseWebSocket);
client.pushUnsubscribe(2);
var lastCall = parseWebSocket.send.calls.first();
var messageJSON = JSON.parse(lastCall.args[0]);
const lastCall = parseWebSocket.send.calls.first();
const messageJSON = JSON.parse(lastCall.args[0]);
expect(messageJSON.op).toBe('unsubscribed');
expect(messageJSON.clientId).toBe(1);
expect(messageJSON.requestId).toBe(2);
});
it('can push create response', function() {
var parseObjectJSON = {
const parseObjectJSON = {
key : 'value',
className: 'test',
objectId: 'test',
@@ -201,14 +201,14 @@ describe('Client', function() {
ACL: 'test',
test: 'test'
};
var parseWebSocket = {
const parseWebSocket = {
send: jasmine.createSpy('send')
};
var client = new Client(1, parseWebSocket);
const client = new Client(1, parseWebSocket);
client.pushCreate(2, parseObjectJSON);
var lastCall = parseWebSocket.send.calls.first();
var messageJSON = JSON.parse(lastCall.args[0]);
const lastCall = parseWebSocket.send.calls.first();
const messageJSON = JSON.parse(lastCall.args[0]);
expect(messageJSON.op).toBe('create');
expect(messageJSON.clientId).toBe(1);
expect(messageJSON.requestId).toBe(2);
@@ -216,7 +216,7 @@ describe('Client', function() {
});
it('can push enter response', function() {
var parseObjectJSON = {
const parseObjectJSON = {
key : 'value',
className: 'test',
objectId: 'test',
@@ -225,14 +225,14 @@ describe('Client', function() {
ACL: 'test',
test: 'test'
};
var parseWebSocket = {
const parseWebSocket = {
send: jasmine.createSpy('send')
};
var client = new Client(1, parseWebSocket);
const client = new Client(1, parseWebSocket);
client.pushEnter(2, parseObjectJSON);
var lastCall = parseWebSocket.send.calls.first();
var messageJSON = JSON.parse(lastCall.args[0]);
const lastCall = parseWebSocket.send.calls.first();
const messageJSON = JSON.parse(lastCall.args[0]);
expect(messageJSON.op).toBe('enter');
expect(messageJSON.clientId).toBe(1);
expect(messageJSON.requestId).toBe(2);
@@ -240,7 +240,7 @@ describe('Client', function() {
});
it('can push update response', function() {
var parseObjectJSON = {
const parseObjectJSON = {
key : 'value',
className: 'test',
objectId: 'test',
@@ -249,14 +249,14 @@ describe('Client', function() {
ACL: 'test',
test: 'test'
};
var parseWebSocket = {
const parseWebSocket = {
send: jasmine.createSpy('send')
};
var client = new Client(1, parseWebSocket);
const client = new Client(1, parseWebSocket);
client.pushUpdate(2, parseObjectJSON);
var lastCall = parseWebSocket.send.calls.first();
var messageJSON = JSON.parse(lastCall.args[0]);
const lastCall = parseWebSocket.send.calls.first();
const messageJSON = JSON.parse(lastCall.args[0]);
expect(messageJSON.op).toBe('update');
expect(messageJSON.clientId).toBe(1);
expect(messageJSON.requestId).toBe(2);
@@ -264,7 +264,7 @@ describe('Client', function() {
});
it('can push leave response', function() {
var parseObjectJSON = {
const parseObjectJSON = {
key : 'value',
className: 'test',
objectId: 'test',
@@ -273,14 +273,14 @@ describe('Client', function() {
ACL: 'test',
test: 'test'
};
var parseWebSocket = {
const parseWebSocket = {
send: jasmine.createSpy('send')
};
var client = new Client(1, parseWebSocket);
const client = new Client(1, parseWebSocket);
client.pushLeave(2, parseObjectJSON);
var lastCall = parseWebSocket.send.calls.first();
var messageJSON = JSON.parse(lastCall.args[0]);
const lastCall = parseWebSocket.send.calls.first();
const messageJSON = JSON.parse(lastCall.args[0]);
expect(messageJSON.op).toBe('leave');
expect(messageJSON.clientId).toBe(1);
expect(messageJSON.requestId).toBe(2);