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