You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-12-19 10:22:30 +03:00
Merge pull request #329 from matrix-org/kegan/eslint2
Fix linting on all tests
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
"build": "babel -s -d lib src && rimraf dist && mkdir dist && browserify --exclude olm browser-index.js -o dist/browser-matrix.js --ignore-missing && uglifyjs -c -m -o dist/browser-matrix.min.js dist/browser-matrix.js",
|
||||
"dist": "npm run build",
|
||||
"watch": "watchify --exclude olm browser-index.js -o dist/browser-matrix-dev.js -v",
|
||||
"lint": "eslint --max-warnings 146 src spec",
|
||||
"lint": "eslint --max-warnings 122 src spec",
|
||||
"prepublish": "npm run lint && npm run build && git rev-parse HEAD > git-revision.txt"
|
||||
},
|
||||
"repository": {
|
||||
|
||||
@@ -3,7 +3,7 @@ let sdk = require("../..");
|
||||
let q = require("q");
|
||||
let HttpBackend = require("../mock-request");
|
||||
let utils = require("../../lib/utils");
|
||||
let test_utils = require("../test-utils");
|
||||
let testUtils = require("../test-utils");
|
||||
|
||||
let aliHttpBackend;
|
||||
let bobHttpBackend;
|
||||
@@ -105,7 +105,7 @@ function expectBobKeyUpload() {
|
||||
}
|
||||
|
||||
function bobUploadsKeys() {
|
||||
bobClient.uploadKeys(5).catch(test_utils.failTest);
|
||||
bobClient.uploadKeys(5).catch(testUtils.failTest);
|
||||
return expectBobKeyUpload();
|
||||
}
|
||||
|
||||
@@ -162,7 +162,8 @@ function expectAliClaimKeys() {
|
||||
aliHttpBackend.when("POST", "/keys/claim").respond(200, function(path, content) {
|
||||
let claimType = content.one_time_keys[bobUserId][bobDeviceId];
|
||||
expect(claimType).toEqual("signed_curve25519");
|
||||
for (var keyId in bobOneTimeKeys) {
|
||||
let keyId = null;
|
||||
for (keyId in bobOneTimeKeys) {
|
||||
if (bobOneTimeKeys.hasOwnProperty(keyId)) {
|
||||
if (keyId.indexOf(claimType + ":") === 0) {
|
||||
break;
|
||||
@@ -343,7 +344,7 @@ function recvMessage(httpBackend, client, sender, message) {
|
||||
syncData.rooms.join[roomId] = {
|
||||
timeline: {
|
||||
events: [
|
||||
test_utils.mkEvent({
|
||||
testUtils.mkEvent({
|
||||
type: "m.room.encrypted",
|
||||
room: roomId,
|
||||
content: message,
|
||||
@@ -382,7 +383,7 @@ function recvMessage(httpBackend, client, sender, message) {
|
||||
|
||||
|
||||
function aliStartClient() {
|
||||
expectAliKeyUpload().catch(test_utils.failTest);
|
||||
expectAliKeyUpload().catch(testUtils.failTest);
|
||||
|
||||
// ali will try to query her own keys on start
|
||||
aliHttpBackend.when("POST", "/keys/query").respond(200, function(path, content) {
|
||||
@@ -399,7 +400,7 @@ function aliStartClient() {
|
||||
}
|
||||
|
||||
function bobStartClient() {
|
||||
expectBobKeyUpload().catch(test_utils.failTest);
|
||||
expectBobKeyUpload().catch(testUtils.failTest);
|
||||
|
||||
// bob will try to query his own keys on start
|
||||
bobHttpBackend.when("POST", "/keys/query").respond(200, function(path, content) {
|
||||
@@ -437,11 +438,11 @@ function startClient(httpBackend, client) {
|
||||
syncData.rooms.join[roomId] = {
|
||||
state: {
|
||||
events: [
|
||||
test_utils.mkMembership({
|
||||
testUtils.mkMembership({
|
||||
mship: "join",
|
||||
user: aliUserId,
|
||||
}),
|
||||
test_utils.mkMembership({
|
||||
testUtils.mkMembership({
|
||||
mship: "join",
|
||||
user: bobUserId,
|
||||
}),
|
||||
@@ -463,9 +464,9 @@ describe("MatrixClient crypto", function() {
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
test_utils.beforeEach(this); // eslint-disable-line no-invalid-this
|
||||
testUtils.beforeEach(this); // eslint-disable-line no-invalid-this
|
||||
|
||||
aliStorage = new sdk.WebStorageSessionStore(new test_utils.MockStorageApi());
|
||||
aliStorage = new sdk.WebStorageSessionStore(new testUtils.MockStorageApi());
|
||||
aliHttpBackend = new HttpBackend();
|
||||
aliClient = sdk.createClient({
|
||||
baseUrl: "http://alis.server",
|
||||
@@ -476,7 +477,7 @@ describe("MatrixClient crypto", function() {
|
||||
request: aliHttpBackend.requestFn,
|
||||
});
|
||||
|
||||
bobStorage = new sdk.WebStorageSessionStore(new test_utils.MockStorageApi());
|
||||
bobStorage = new sdk.WebStorageSessionStore(new testUtils.MockStorageApi());
|
||||
bobHttpBackend = new HttpBackend();
|
||||
bobClient = sdk.createClient({
|
||||
baseUrl: "http://bobs.server",
|
||||
@@ -525,14 +526,14 @@ describe("MatrixClient crypto", function() {
|
||||
it("Bob uploads without one-time keys and with one-time keys", function(done) {
|
||||
q()
|
||||
.then(bobUploadsKeys)
|
||||
.catch(test_utils.failTest).done(done);
|
||||
.catch(testUtils.failTest).done(done);
|
||||
});
|
||||
|
||||
it("Ali downloads Bobs keys", function(done) {
|
||||
q()
|
||||
.then(bobUploadsKeys)
|
||||
.then(aliDownloadsKeys)
|
||||
.catch(test_utils.failTest).done(done);
|
||||
.catch(testUtils.failTest).done(done);
|
||||
});
|
||||
|
||||
it("Ali gets keys with an invalid signature", function(done) {
|
||||
@@ -550,7 +551,7 @@ describe("MatrixClient crypto", function() {
|
||||
// should get an empty list
|
||||
expect(aliClient.listDeviceKeys(bobUserId)).toEqual([]);
|
||||
})
|
||||
.catch(test_utils.failTest).done(done);
|
||||
.catch(testUtils.failTest).done(done);
|
||||
});
|
||||
|
||||
it("Ali gets keys with an incorrect userId", function(done) {
|
||||
@@ -587,7 +588,7 @@ describe("MatrixClient crypto", function() {
|
||||
// should get an empty list
|
||||
expect(aliClient.listDeviceKeys(bobUserId)).toEqual([]);
|
||||
expect(aliClient.listDeviceKeys(eveUserId)).toEqual([]);
|
||||
}).catch(test_utils.failTest).done(done);
|
||||
}).catch(testUtils.failTest).done(done);
|
||||
});
|
||||
|
||||
it("Ali gets keys with an incorrect deviceId", function(done) {
|
||||
@@ -621,7 +622,7 @@ describe("MatrixClient crypto", function() {
|
||||
).then(function() {
|
||||
// should get an empty list
|
||||
expect(aliClient.listDeviceKeys(bobUserId)).toEqual([]);
|
||||
}).catch(test_utils.failTest).done(done);
|
||||
}).catch(testUtils.failTest).done(done);
|
||||
});
|
||||
|
||||
it("Ali enables encryption", function(done) {
|
||||
@@ -629,7 +630,7 @@ describe("MatrixClient crypto", function() {
|
||||
.then(bobUploadsKeys)
|
||||
.then(aliStartClient)
|
||||
.then(aliEnablesEncryption)
|
||||
.catch(test_utils.failTest).done(done);
|
||||
.catch(testUtils.failTest).done(done);
|
||||
});
|
||||
|
||||
it("Ali sends a message", function(done) {
|
||||
@@ -638,7 +639,7 @@ describe("MatrixClient crypto", function() {
|
||||
.then(aliStartClient)
|
||||
.then(aliEnablesEncryption)
|
||||
.then(aliSendsFirstMessage)
|
||||
.catch(test_utils.failTest).nodeify(done);
|
||||
.catch(testUtils.failTest).nodeify(done);
|
||||
});
|
||||
|
||||
it("Bob receives a message", function(done) {
|
||||
@@ -649,7 +650,7 @@ describe("MatrixClient crypto", function() {
|
||||
.then(aliSendsFirstMessage)
|
||||
.then(bobStartClient)
|
||||
.then(bobRecvMessage)
|
||||
.catch(test_utils.failTest).done(done);
|
||||
.catch(testUtils.failTest).done(done);
|
||||
});
|
||||
|
||||
it("Bob receives a message with a bogus sender", function(done) {
|
||||
@@ -672,7 +673,7 @@ describe("MatrixClient crypto", function() {
|
||||
syncData.rooms.join[roomId] = {
|
||||
timeline: {
|
||||
events: [
|
||||
test_utils.mkEvent({
|
||||
testUtils.mkEvent({
|
||||
type: "m.room.encrypted",
|
||||
room: roomId,
|
||||
content: message,
|
||||
@@ -706,7 +707,7 @@ describe("MatrixClient crypto", function() {
|
||||
bobHttpBackend.flush();
|
||||
return deferred.promise;
|
||||
})
|
||||
.catch(test_utils.failTest).done(done);
|
||||
.catch(testUtils.failTest).done(done);
|
||||
});
|
||||
|
||||
it("Ali blocks Bob's device", function(done) {
|
||||
@@ -727,7 +728,7 @@ describe("MatrixClient crypto", function() {
|
||||
expect(sentContent.ciphertext).toEqual({});
|
||||
});
|
||||
return q.all([p1, p2]);
|
||||
}).catch(test_utils.failTest).nodeify(done);
|
||||
}).catch(testUtils.failTest).nodeify(done);
|
||||
});
|
||||
|
||||
it("Bob receives two pre-key messages", function(done) {
|
||||
@@ -740,7 +741,7 @@ describe("MatrixClient crypto", function() {
|
||||
.then(bobRecvMessage)
|
||||
.then(aliSendsMessage)
|
||||
.then(bobRecvMessage)
|
||||
.catch(test_utils.failTest).done(done);
|
||||
.catch(testUtils.failTest).done(done);
|
||||
});
|
||||
|
||||
it("Bob replies to the message", function(done) {
|
||||
@@ -755,7 +756,7 @@ describe("MatrixClient crypto", function() {
|
||||
.then(bobSendsReplyMessage).then(function(ciphertext) {
|
||||
expect(ciphertext.type).toEqual(1);
|
||||
}).then(aliRecvMessage)
|
||||
.catch(test_utils.failTest).done(done);
|
||||
.catch(testUtils.failTest).done(done);
|
||||
});
|
||||
|
||||
|
||||
@@ -768,7 +769,7 @@ describe("MatrixClient crypto", function() {
|
||||
next_batch: '2',
|
||||
to_device: {
|
||||
events: [
|
||||
test_utils.mkEvent({
|
||||
testUtils.mkEvent({
|
||||
content: {
|
||||
device_id: 'TEST_DEVICE',
|
||||
rooms: [],
|
||||
|
||||
@@ -220,7 +220,8 @@ describe("getEventTimeline support", function() {
|
||||
});
|
||||
|
||||
describe("MatrixClient event timelines", function() {
|
||||
let client, httpBackend;
|
||||
let client = null;
|
||||
let httpBackend = null;
|
||||
|
||||
beforeEach(function(done) {
|
||||
utils.beforeEach(this); // eslint-disable-line no-invalid-this
|
||||
@@ -417,7 +418,8 @@ describe("MatrixClient event timelines", function() {
|
||||
};
|
||||
});
|
||||
|
||||
let tl0, tl3;
|
||||
let tl0;
|
||||
let tl3;
|
||||
client.getEventTimeline(timelineSet, EVENTS[0].event_id
|
||||
).then(function(tl) {
|
||||
expect(tl.getEvents().length).toEqual(1);
|
||||
|
||||
@@ -10,7 +10,10 @@ let MockStorageApi = require("../MockStorageApi");
|
||||
|
||||
describe("MatrixClient", function() {
|
||||
let baseUrl = "http://localhost.or.something";
|
||||
let client, httpBackend, store, sessionStore;
|
||||
let client = null;
|
||||
let httpBackend = null;
|
||||
let store = null;
|
||||
let sessionStore = null;
|
||||
let userId = "@alice:localhost";
|
||||
let accessToken = "aseukfgwef";
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@ let utils = require("../test-utils");
|
||||
|
||||
describe("MatrixClient opts", function() {
|
||||
let baseUrl = "http://localhost.or.something";
|
||||
let client, httpBackend;
|
||||
let client = null;
|
||||
let httpBackend = null;
|
||||
let userId = "@alice:localhost";
|
||||
let userB = "@bob:localhost";
|
||||
let accessToken = "aseukfgwef";
|
||||
|
||||
@@ -6,7 +6,8 @@ let EventStatus = sdk.EventStatus;
|
||||
|
||||
describe("MatrixClient retrying", function() {
|
||||
let baseUrl = "http://localhost.or.something";
|
||||
let client, httpBackend;
|
||||
let client = null;
|
||||
let httpBackend = null;
|
||||
let scheduler;
|
||||
let userId = "@alice:localhost";
|
||||
let accessToken = "aseukfgwef";
|
||||
@@ -50,7 +51,8 @@ describe("MatrixClient retrying", function() {
|
||||
|
||||
it("should mark events as EventStatus.CANCELLED when cancelled", function(done) {
|
||||
// send a couple of events; the second will be queued
|
||||
let ev1, ev2;
|
||||
let ev1;
|
||||
let ev2;
|
||||
client.sendMessage(roomId, "m1").then(function(ev) {
|
||||
expect(ev).toEqual(ev1);
|
||||
});
|
||||
|
||||
@@ -6,7 +6,8 @@ let utils = require("../test-utils");
|
||||
|
||||
describe("MatrixClient room timelines", function() {
|
||||
let baseUrl = "http://localhost.or.something";
|
||||
let client, httpBackend;
|
||||
let client = null;
|
||||
let httpBackend = null;
|
||||
let userId = "@alice:localhost";
|
||||
let userName = "Alice";
|
||||
let accessToken = "aseukfgwef";
|
||||
|
||||
@@ -7,7 +7,8 @@ let EventTimeline = sdk.EventTimeline;
|
||||
|
||||
describe("MatrixClient syncing", function() {
|
||||
let baseUrl = "http://localhost.or.something";
|
||||
let client, httpBackend;
|
||||
let client = null;
|
||||
let httpBackend = null;
|
||||
let selfUserId = "@alice:localhost";
|
||||
let selfAccessToken = "aseukfgwef";
|
||||
let otherUserId = "@bob:localhost";
|
||||
|
||||
@@ -17,8 +17,9 @@ limitations under the License.
|
||||
"use strict";
|
||||
|
||||
|
||||
let Olm = null;
|
||||
try {
|
||||
var Olm = require('olm');
|
||||
Olm = require('olm');
|
||||
} catch (e) {}
|
||||
|
||||
let anotherjson = require('another-json');
|
||||
@@ -26,7 +27,7 @@ let q = require('q');
|
||||
|
||||
let sdk = require('../..');
|
||||
let utils = require('../../lib/utils');
|
||||
let test_utils = require('../test-utils');
|
||||
let testUtils = require('../test-utils');
|
||||
let MockHttpBackend = require('../mock-request');
|
||||
|
||||
let ROOM_ID = "!room:id";
|
||||
@@ -43,7 +44,7 @@ function TestClient(userId, deviceId, accessToken) {
|
||||
this.userId = userId;
|
||||
this.deviceId = deviceId;
|
||||
|
||||
this.storage = new sdk.WebStorageSessionStore(new test_utils.MockStorageApi());
|
||||
this.storage = new sdk.WebStorageSessionStore(new testUtils.MockStorageApi());
|
||||
this.httpBackend = new MockHttpBackend();
|
||||
this.client = sdk.createClient({
|
||||
baseUrl: "http://test.server",
|
||||
@@ -114,8 +115,8 @@ TestClient.prototype.stop = function() {
|
||||
* @return {string} base64 device key
|
||||
*/
|
||||
TestClient.prototype.getDeviceKey = function() {
|
||||
let key_id = 'curve25519:' + this.deviceId;
|
||||
return this.deviceKeys.keys[key_id];
|
||||
let keyId = 'curve25519:' + this.deviceId;
|
||||
return this.deviceKeys.keys[keyId];
|
||||
};
|
||||
|
||||
|
||||
@@ -125,8 +126,8 @@ TestClient.prototype.getDeviceKey = function() {
|
||||
* @return {string} base64 device key
|
||||
*/
|
||||
TestClient.prototype.getSigningKey = function() {
|
||||
let key_id = 'ed25519:' + this.deviceId;
|
||||
return this.deviceKeys.keys[key_id];
|
||||
let keyId = 'ed25519:' + this.deviceId;
|
||||
return this.deviceKeys.keys[keyId];
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -137,8 +138,8 @@ TestClient.prototype.getSigningKey = function() {
|
||||
* @return {Olm.Session}
|
||||
*/
|
||||
function createOlmSession(olmAccount, recipientTestClient) {
|
||||
let otk_id = utils.keys(recipientTestClient.oneTimeKeys)[0];
|
||||
let otk = recipientTestClient.oneTimeKeys[otk_id];
|
||||
let otkId = utils.keys(recipientTestClient.oneTimeKeys)[0];
|
||||
let otk = recipientTestClient.oneTimeKeys[otkId];
|
||||
|
||||
let session = new Olm.Session();
|
||||
session.create_outbound(
|
||||
@@ -270,7 +271,7 @@ function getSyncResponse(roomMembers) {
|
||||
let roomResponse = {
|
||||
state: {
|
||||
events: [
|
||||
test_utils.mkEvent({
|
||||
testUtils.mkEvent({
|
||||
type: 'm.room.encryption',
|
||||
skey: '',
|
||||
content: {
|
||||
@@ -283,7 +284,7 @@ function getSyncResponse(roomMembers) {
|
||||
|
||||
for (let i = 0; i < roomMembers.length; i++) {
|
||||
roomResponse.state.events.push(
|
||||
test_utils.mkMembership({
|
||||
testUtils.mkMembership({
|
||||
mship: 'join',
|
||||
sender: roomMembers[i],
|
||||
})
|
||||
@@ -380,7 +381,7 @@ describe("megolm", function() {
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
test_utils.beforeEach(this); // eslint-disable-line no-invalid-this
|
||||
testUtils.beforeEach(this); // eslint-disable-line no-invalid-this
|
||||
|
||||
aliceTestClient = new TestClient(
|
||||
"@alice:localhost", "xzcvb", "akjgkrgjs"
|
||||
@@ -755,14 +756,14 @@ describe("megolm", function() {
|
||||
syncResponse.rooms.join[ROOM_ID] = {
|
||||
state: {
|
||||
events: [
|
||||
test_utils.mkEvent({
|
||||
testUtils.mkEvent({
|
||||
type: 'm.room.encryption',
|
||||
skey: '',
|
||||
content: {
|
||||
algorithm: 'm.megolm.v1.aes-sha2',
|
||||
},
|
||||
}),
|
||||
test_utils.mkMembership({
|
||||
testUtils.mkMembership({
|
||||
mship: 'join',
|
||||
sender: aliceTestClient.userId,
|
||||
}),
|
||||
|
||||
@@ -84,8 +84,11 @@ HttpBackend.prototype = {
|
||||
*/
|
||||
_takeFromQueue: function(path) {
|
||||
let req = null;
|
||||
let i, j;
|
||||
let matchingReq, expectedReq, testResponse = null;
|
||||
let i;
|
||||
let j;
|
||||
let matchingReq = null;
|
||||
let expectedReq = null;
|
||||
let testResponse = null;
|
||||
for (i = 0; i < this.requests.length; i++) {
|
||||
req = this.requests[i];
|
||||
for (j = 0; j < this.expectedRequests.length; j++) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
let callbacks = require("../../lib/realtime-callbacks");
|
||||
let test_utils = require("../test-utils.js");
|
||||
let testUtils = require("../test-utils.js");
|
||||
|
||||
describe("realtime-callbacks", function() {
|
||||
let clock = jasmine.Clock;
|
||||
@@ -14,7 +14,7 @@ describe("realtime-callbacks", function() {
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
test_utils.beforeEach(this); // eslint-disable-line no-invalid-this
|
||||
testUtils.beforeEach(this); // eslint-disable-line no-invalid-this
|
||||
clock.useMock();
|
||||
fakeDate = Date.now();
|
||||
callbacks.setNow(function() {
|
||||
|
||||
@@ -9,7 +9,8 @@ let utils = require("../test-utils");
|
||||
|
||||
describe("MatrixScheduler", function() {
|
||||
let scheduler;
|
||||
let retryFn, queueFn;
|
||||
let retryFn;
|
||||
let queueFn;
|
||||
let defer;
|
||||
let roomId = "!foo:bar";
|
||||
let eventA = utils.mkMessage({
|
||||
|
||||
@@ -100,7 +100,8 @@ describe("TimelineIndex", function() {
|
||||
|
||||
it("should advance into the next timeline", function() {
|
||||
let timelines = createLinkedTimelines();
|
||||
let tl1 = timelines[0], tl2 = timelines[1];
|
||||
let tl1 = timelines[0];
|
||||
let tl2 = timelines[1];
|
||||
|
||||
// initialise the index pointing at the end of the first timeline
|
||||
let timelineIndex = new TimelineIndex(tl1, 2);
|
||||
@@ -117,7 +118,8 @@ describe("TimelineIndex", function() {
|
||||
|
||||
it("should retreat into the previous timeline", function() {
|
||||
let timelines = createLinkedTimelines();
|
||||
let tl1 = timelines[0], tl2 = timelines[1];
|
||||
let tl1 = timelines[0];
|
||||
let tl2 = timelines[1];
|
||||
|
||||
// initialise the index pointing at the start of the second
|
||||
// timeline
|
||||
@@ -146,7 +148,8 @@ describe("TimelineWindow", function() {
|
||||
* create a dummy eventTimelineSet and client, and a TimelineWindow
|
||||
* attached to them.
|
||||
*/
|
||||
let timelineSet, client;
|
||||
let timelineSet;
|
||||
let client;
|
||||
function createWindow(timeline, opts) {
|
||||
timelineSet = {};
|
||||
client = {};
|
||||
|
||||
@@ -241,13 +241,13 @@ describe("utils", function() {
|
||||
"prop1": 5, "prop2": 1, "string1": "baz", "string2": "x",
|
||||
"newprop": "new",
|
||||
};
|
||||
let source_orig = JSON.stringify(SOURCE);
|
||||
let sourceOrig = JSON.stringify(SOURCE);
|
||||
|
||||
utils.extend(target, SOURCE);
|
||||
expect(JSON.stringify(target)).toEqual(JSON.stringify(merged));
|
||||
|
||||
// check the originial wasn't modified
|
||||
expect(JSON.stringify(SOURCE)).toEqual(source_orig);
|
||||
expect(JSON.stringify(SOURCE)).toEqual(sourceOrig);
|
||||
});
|
||||
|
||||
it("should ignore null", function() {
|
||||
@@ -258,13 +258,13 @@ describe("utils", function() {
|
||||
"prop1": 5, "prop2": 1, "string1": "baz", "string2": "x",
|
||||
"newprop": "new",
|
||||
};
|
||||
let source_orig = JSON.stringify(SOURCE);
|
||||
let sourceOrig = JSON.stringify(SOURCE);
|
||||
|
||||
utils.extend(target, null, SOURCE);
|
||||
expect(JSON.stringify(target)).toEqual(JSON.stringify(merged));
|
||||
|
||||
// check the originial wasn't modified
|
||||
expect(JSON.stringify(SOURCE)).toEqual(source_orig);
|
||||
expect(JSON.stringify(SOURCE)).toEqual(sourceOrig);
|
||||
});
|
||||
|
||||
it("should handle properties created with defineProperties", function() {
|
||||
|
||||
Reference in New Issue
Block a user