You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
Convert tests to ES6
The earlier commit, d3ce0cb82f, has most of the juicy details on this. In addition to d3ce's changes, we also:
* Use `TestClient` in many integration tests due to subtle behaviour changes in imports when switching to ES6. Namely the behaviour where setting the request function is less reliable in the way we did it, but `TestClient` is very reliable.
* We now use the Olm loader more often to avoid having to maintain so much duplicate code. This makes the imports slightly easier to read.
This commit is contained in:
@@ -81,5 +81,8 @@
|
|||||||
"source-map-support": "^0.5.13",
|
"source-map-support": "^0.5.13",
|
||||||
"tslint": "^5.20.1",
|
"tslint": "^5.20.1",
|
||||||
"typescript": "^3.7.3"
|
"typescript": "^3.7.3"
|
||||||
|
},
|
||||||
|
"jest": {
|
||||||
|
"testEnvironment": "node"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2015, 2016 OpenMarket Ltd
|
Copyright 2015, 2016 OpenMarket Ltd
|
||||||
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -18,7 +19,7 @@ limitations under the License.
|
|||||||
* A mock implementation of the webstorage api
|
* A mock implementation of the webstorage api
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function MockStorageApi() {
|
export function MockStorageApi() {
|
||||||
this.data = {};
|
this.data = {};
|
||||||
this.keys = [];
|
this.keys = [];
|
||||||
this.length = 0;
|
this.length = 0;
|
||||||
@@ -52,5 +53,3 @@ MockStorageApi.prototype = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/** */
|
|
||||||
module.exports = MockStorageApi;
|
|
||||||
|
|||||||
@@ -21,11 +21,13 @@ limitations under the License.
|
|||||||
// load olm before the sdk if possible
|
// load olm before the sdk if possible
|
||||||
import './olm-loader';
|
import './olm-loader';
|
||||||
|
|
||||||
import sdk from '..';
|
|
||||||
import testUtils from './test-utils';
|
|
||||||
import MockHttpBackend from 'matrix-mock-request';
|
import MockHttpBackend from 'matrix-mock-request';
|
||||||
import LocalStorageCryptoStore from '../lib/crypto/store/localStorage-crypto-store';
|
import {LocalStorageCryptoStore} from '../src/crypto/store/localStorage-crypto-store';
|
||||||
import logger from '../lib/logger';
|
import {logger} from '../src/logger';
|
||||||
|
import {WebStorageSessionStore} from "../src/store/session/webstorage";
|
||||||
|
import {syncPromise} from "./test-utils";
|
||||||
|
import {createClient} from "../src/matrix";
|
||||||
|
import {MockStorageApi} from "./MockStorageApi";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for a MockStorageApi, MockHttpBackend and MatrixClient
|
* Wrapper for a MockStorageApi, MockHttpBackend and MatrixClient
|
||||||
@@ -39,16 +41,16 @@ import logger from '../lib/logger';
|
|||||||
* session store. If undefined, we will create a MockStorageApi.
|
* session store. If undefined, we will create a MockStorageApi.
|
||||||
* @param {object} options additional options to pass to the client
|
* @param {object} options additional options to pass to the client
|
||||||
*/
|
*/
|
||||||
export default function TestClient(
|
export function TestClient(
|
||||||
userId, deviceId, accessToken, sessionStoreBackend, options,
|
userId, deviceId, accessToken, sessionStoreBackend, options,
|
||||||
) {
|
) {
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
this.deviceId = deviceId;
|
this.deviceId = deviceId;
|
||||||
|
|
||||||
if (sessionStoreBackend === undefined) {
|
if (sessionStoreBackend === undefined) {
|
||||||
sessionStoreBackend = new testUtils.MockStorageApi();
|
sessionStoreBackend = new MockStorageApi();
|
||||||
}
|
}
|
||||||
const sessionStore = new sdk.WebStorageSessionStore(sessionStoreBackend);
|
const sessionStore = new WebStorageSessionStore(sessionStoreBackend);
|
||||||
|
|
||||||
this.httpBackend = new MockHttpBackend();
|
this.httpBackend = new MockHttpBackend();
|
||||||
|
|
||||||
@@ -65,7 +67,7 @@ export default function TestClient(
|
|||||||
this.cryptoStore = new LocalStorageCryptoStore(sessionStoreBackend);
|
this.cryptoStore = new LocalStorageCryptoStore(sessionStoreBackend);
|
||||||
options.cryptoStore = this.cryptoStore;
|
options.cryptoStore = this.cryptoStore;
|
||||||
}
|
}
|
||||||
this.client = sdk.createClient(options);
|
this.client = createClient(options);
|
||||||
|
|
||||||
this.deviceKeys = null;
|
this.deviceKeys = null;
|
||||||
this.oneTimeKeys = {};
|
this.oneTimeKeys = {};
|
||||||
@@ -97,7 +99,7 @@ TestClient.prototype.start = function() {
|
|||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
this.httpBackend.flushAllExpected(),
|
this.httpBackend.flushAllExpected(),
|
||||||
testUtils.syncPromise(this.client),
|
syncPromise(this.client),
|
||||||
]).then(() => {
|
]).then(() => {
|
||||||
logger.log(this + ': started');
|
logger.log(this + ': started');
|
||||||
});
|
});
|
||||||
@@ -225,7 +227,7 @@ TestClient.prototype.flushSync = function() {
|
|||||||
logger.log(`${this}: flushSync`);
|
logger.log(`${this}: flushSync`);
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
this.httpBackend.flush('/sync', 1),
|
this.httpBackend.flush('/sync', 1),
|
||||||
testUtils.syncPromise(this.client),
|
syncPromise(this.client),
|
||||||
]).then(() => {
|
]).then(() => {
|
||||||
logger.log(`${this}: flushSync completed`);
|
logger.log(`${this}: flushSync completed`);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2017 Vector Creations Ltd
|
Copyright 2017 Vector Creations Ltd
|
||||||
Copyright 2018 New Vector Ltd
|
Copyright 2018 New Vector Ltd
|
||||||
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -15,9 +16,9 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import TestClient from '../TestClient';
|
import {TestClient} from '../TestClient';
|
||||||
import testUtils from '../test-utils';
|
import * as testUtils from '../test-utils';
|
||||||
import logger from '../../lib/logger';
|
import {logger} from '../../src/logger';
|
||||||
|
|
||||||
const ROOM_ID = "!room:id";
|
const ROOM_ID = "!room:id";
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
Copyright 2016 OpenMarket Ltd
|
Copyright 2016 OpenMarket Ltd
|
||||||
Copyright 2017 Vector Creations Ltd
|
Copyright 2017 Vector Creations Ltd
|
||||||
Copyright 2018 New Vector Ltd
|
Copyright 2018 New Vector Ltd
|
||||||
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -30,11 +31,11 @@ import 'source-map-support/register';
|
|||||||
// load olm before the sdk if possible
|
// load olm before the sdk if possible
|
||||||
import '../olm-loader';
|
import '../olm-loader';
|
||||||
|
|
||||||
const sdk = require("../..");
|
import {logger} from '../../src/logger';
|
||||||
const utils = require("../../lib/utils");
|
import * as testUtils from "../test-utils";
|
||||||
const testUtils = require("../test-utils");
|
import * as utils from "../../src/utils";
|
||||||
const TestClient = require('../TestClient').default;
|
import {TestClient} from "../TestClient";
|
||||||
import logger from '../../lib/logger';
|
import {CRYPTO_ENABLED} from "../../src/client";
|
||||||
|
|
||||||
let aliTestClient;
|
let aliTestClient;
|
||||||
const roomId = "!room:localhost";
|
const roomId = "!room:localhost";
|
||||||
@@ -400,7 +401,7 @@ function firstSync(testClient) {
|
|||||||
|
|
||||||
|
|
||||||
describe("MatrixClient crypto", function() {
|
describe("MatrixClient crypto", function() {
|
||||||
if (!sdk.CRYPTO_ENABLED) {
|
if (!CRYPTO_ENABLED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,18 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
const sdk = require("../..");
|
import * as utils from "../test-utils";
|
||||||
const HttpBackend = require("matrix-mock-request");
|
import {TestClient} from "../TestClient";
|
||||||
const utils = require("../test-utils");
|
|
||||||
|
|
||||||
describe("MatrixClient events", function() {
|
describe("MatrixClient events", function() {
|
||||||
const baseUrl = "http://localhost.or.something";
|
|
||||||
let client;
|
let client;
|
||||||
let httpBackend;
|
let httpBackend;
|
||||||
const selfUserId = "@alice:localhost";
|
const selfUserId = "@alice:localhost";
|
||||||
const selfAccessToken = "aseukfgwef";
|
const selfAccessToken = "aseukfgwef";
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
httpBackend = new HttpBackend();
|
const testClient = new TestClient(selfUserId, "DEVICE", selfAccessToken);
|
||||||
sdk.request(httpBackend.requestFn);
|
client = testClient.client;
|
||||||
client = sdk.createClient({
|
httpBackend = testClient.httpBackend;
|
||||||
baseUrl: baseUrl,
|
|
||||||
userId: selfUserId,
|
|
||||||
accessToken: selfAccessToken,
|
|
||||||
});
|
|
||||||
httpBackend.when("GET", "/pushrules").respond(200, {});
|
httpBackend.when("GET", "/pushrules").respond(200, {});
|
||||||
httpBackend.when("POST", "/filter").respond(200, { filter_id: "a filter id" });
|
httpBackend.when("POST", "/filter").respond(200, { filter_id: "a filter id" });
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
const sdk = require("../..");
|
import * as utils from "../test-utils";
|
||||||
const HttpBackend = require("matrix-mock-request");
|
import {EventTimeline} from "../../src/matrix";
|
||||||
const utils = require("../test-utils");
|
import {logger} from "../../src/logger";
|
||||||
const EventTimeline = sdk.EventTimeline;
|
import {TestClient} from "../TestClient";
|
||||||
import logger from '../../lib/logger';
|
|
||||||
|
|
||||||
const baseUrl = "http://localhost.or.something";
|
|
||||||
const userId = "@alice:localhost";
|
const userId = "@alice:localhost";
|
||||||
const userName = "Alice";
|
const userName = "Alice";
|
||||||
const accessToken = "aseukfgwef";
|
const accessToken = "aseukfgwef";
|
||||||
@@ -103,8 +101,9 @@ describe("getEventTimeline support", function() {
|
|||||||
let client;
|
let client;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
httpBackend = new HttpBackend();
|
const testClient = new TestClient(userId, "DEVICE", accessToken);
|
||||||
sdk.request(httpBackend.requestFn);
|
client = testClient.client;
|
||||||
|
httpBackend = testClient.httpBackend;
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
@@ -115,12 +114,6 @@ describe("getEventTimeline support", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("timeline support must be enabled to work", function() {
|
it("timeline support must be enabled to work", function() {
|
||||||
client = sdk.createClient({
|
|
||||||
baseUrl: baseUrl,
|
|
||||||
userId: userId,
|
|
||||||
accessToken: accessToken,
|
|
||||||
});
|
|
||||||
|
|
||||||
return startClient(httpBackend, client).then(function() {
|
return startClient(httpBackend, client).then(function() {
|
||||||
const room = client.getRoom(roomId);
|
const room = client.getRoom(roomId);
|
||||||
const timelineSet = room.getTimelineSets()[0];
|
const timelineSet = room.getTimelineSets()[0];
|
||||||
@@ -131,12 +124,15 @@ describe("getEventTimeline support", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("timeline support works when enabled", function() {
|
it("timeline support works when enabled", function() {
|
||||||
client = sdk.createClient({
|
const testClient = new TestClient(
|
||||||
baseUrl: baseUrl,
|
userId,
|
||||||
userId: userId,
|
"DEVICE",
|
||||||
accessToken: accessToken,
|
accessToken,
|
||||||
timelineSupport: true,
|
undefined,
|
||||||
});
|
{timelineSupport: true},
|
||||||
|
);
|
||||||
|
client = testClient.client;
|
||||||
|
httpBackend = testClient.httpBackend;
|
||||||
|
|
||||||
return startClient(httpBackend, client).then(() => {
|
return startClient(httpBackend, client).then(() => {
|
||||||
const room = client.getRoom(roomId);
|
const room = client.getRoom(roomId);
|
||||||
@@ -151,11 +147,7 @@ describe("getEventTimeline support", function() {
|
|||||||
it("scrollback should be able to scroll back to before a gappy /sync",
|
it("scrollback should be able to scroll back to before a gappy /sync",
|
||||||
function() {
|
function() {
|
||||||
// need a client with timelineSupport disabled to make this work
|
// need a client with timelineSupport disabled to make this work
|
||||||
client = sdk.createClient({
|
|
||||||
baseUrl: baseUrl,
|
|
||||||
userId: userId,
|
|
||||||
accessToken: accessToken,
|
|
||||||
});
|
|
||||||
let room;
|
let room;
|
||||||
|
|
||||||
return startClient(httpBackend, client).then(function() {
|
return startClient(httpBackend, client).then(function() {
|
||||||
@@ -223,15 +215,15 @@ describe("MatrixClient event timelines", function() {
|
|||||||
let httpBackend = null;
|
let httpBackend = null;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
httpBackend = new HttpBackend();
|
const testClient = new TestClient(
|
||||||
sdk.request(httpBackend.requestFn);
|
userId,
|
||||||
|
"DEVICE",
|
||||||
client = sdk.createClient({
|
accessToken,
|
||||||
baseUrl: baseUrl,
|
undefined,
|
||||||
userId: userId,
|
{timelineSupport: true},
|
||||||
accessToken: accessToken,
|
);
|
||||||
timelineSupport: true,
|
client = testClient.client;
|
||||||
});
|
httpBackend = testClient.httpBackend;
|
||||||
|
|
||||||
return startClient(httpBackend, client);
|
return startClient(httpBackend, client);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,39 +1,25 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
const sdk = require("../..");
|
import * as utils from "../test-utils";
|
||||||
const HttpBackend = require("matrix-mock-request");
|
import {CRYPTO_ENABLED} from "../../src/client";
|
||||||
const publicGlobals = require("../../lib/matrix");
|
import {Filter, MemoryStore, Room} from "../../src/matrix";
|
||||||
const Room = publicGlobals.Room;
|
import {TestClient} from "../TestClient";
|
||||||
const MemoryStore = publicGlobals.MemoryStore;
|
|
||||||
const Filter = publicGlobals.Filter;
|
|
||||||
const utils = require("../test-utils");
|
|
||||||
const MockStorageApi = require("../MockStorageApi");
|
|
||||||
|
|
||||||
describe("MatrixClient", function() {
|
describe("MatrixClient", function() {
|
||||||
const baseUrl = "http://localhost.or.something";
|
|
||||||
let client = null;
|
let client = null;
|
||||||
let httpBackend = null;
|
let httpBackend = null;
|
||||||
let store = null;
|
let store = null;
|
||||||
let sessionStore = null;
|
|
||||||
const userId = "@alice:localhost";
|
const userId = "@alice:localhost";
|
||||||
const accessToken = "aseukfgwef";
|
const accessToken = "aseukfgwef";
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
httpBackend = new HttpBackend();
|
|
||||||
store = new MemoryStore();
|
store = new MemoryStore();
|
||||||
|
|
||||||
const mockStorage = new MockStorageApi();
|
const testClient = new TestClient(userId, "aliceDevice", accessToken, undefined, {
|
||||||
sessionStore = new sdk.WebStorageSessionStore(mockStorage);
|
|
||||||
|
|
||||||
sdk.request(httpBackend.requestFn);
|
|
||||||
client = sdk.createClient({
|
|
||||||
baseUrl: baseUrl,
|
|
||||||
userId: userId,
|
|
||||||
deviceId: "aliceDevice",
|
|
||||||
accessToken: accessToken,
|
|
||||||
store: store,
|
store: store,
|
||||||
sessionStore: sessionStore,
|
|
||||||
});
|
});
|
||||||
|
httpBackend = testClient.httpBackend;
|
||||||
|
client = testClient.client;
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
@@ -303,7 +289,7 @@ describe("MatrixClient", function() {
|
|||||||
|
|
||||||
|
|
||||||
describe("downloadKeys", function() {
|
describe("downloadKeys", function() {
|
||||||
if (!sdk.CRYPTO_ENABLED) {
|
if (!CRYPTO_ENABLED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
const sdk = require("../..");
|
import * as utils from "../test-utils";
|
||||||
const MatrixClient = sdk.MatrixClient;
|
import HttpBackend from "matrix-mock-request";
|
||||||
const HttpBackend = require("matrix-mock-request");
|
import {MatrixClient} from "../../src/matrix";
|
||||||
const utils = require("../test-utils");
|
import {MatrixScheduler} from "../../src/scheduler";
|
||||||
|
import {MemoryStore} from "../../src/store/memory";
|
||||||
|
|
||||||
describe("MatrixClient opts", function() {
|
describe("MatrixClient opts", function() {
|
||||||
const baseUrl = "http://localhost.or.something";
|
const baseUrl = "http://localhost.or.something";
|
||||||
@@ -71,7 +72,7 @@ describe("MatrixClient opts", function() {
|
|||||||
baseUrl: baseUrl,
|
baseUrl: baseUrl,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
accessToken: accessToken,
|
accessToken: accessToken,
|
||||||
scheduler: new sdk.MatrixScheduler(),
|
scheduler: new MatrixScheduler(),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -124,7 +125,7 @@ describe("MatrixClient opts", function() {
|
|||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
client = new MatrixClient({
|
client = new MatrixClient({
|
||||||
request: httpBackend.requestFn,
|
request: httpBackend.requestFn,
|
||||||
store: new sdk.MemoryStore(),
|
store: new MemoryStore(),
|
||||||
baseUrl: baseUrl,
|
baseUrl: baseUrl,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
accessToken: accessToken,
|
accessToken: accessToken,
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
|
import {EventStatus} from "../../src/matrix";
|
||||||
const sdk = require("../..");
|
import {MatrixScheduler} from "../../src/scheduler";
|
||||||
const HttpBackend = require("matrix-mock-request");
|
import {Room} from "../../src/models/room";
|
||||||
const EventStatus = sdk.EventStatus;
|
import {TestClient} from "../TestClient";
|
||||||
|
|
||||||
describe("MatrixClient retrying", function() {
|
describe("MatrixClient retrying", function() {
|
||||||
const baseUrl = "http://localhost.or.something";
|
|
||||||
let client = null;
|
let client = null;
|
||||||
let httpBackend = null;
|
let httpBackend = null;
|
||||||
let scheduler;
|
let scheduler;
|
||||||
@@ -16,16 +15,17 @@ describe("MatrixClient retrying", function() {
|
|||||||
let room;
|
let room;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
httpBackend = new HttpBackend();
|
scheduler = new MatrixScheduler();
|
||||||
sdk.request(httpBackend.requestFn);
|
const testClient = new TestClient(
|
||||||
scheduler = new sdk.MatrixScheduler();
|
userId,
|
||||||
client = sdk.createClient({
|
"DEVICE",
|
||||||
baseUrl: baseUrl,
|
accessToken,
|
||||||
userId: userId,
|
undefined,
|
||||||
accessToken: accessToken,
|
{scheduler},
|
||||||
scheduler: scheduler,
|
);
|
||||||
});
|
httpBackend = testClient.httpBackend;
|
||||||
room = new sdk.Room(roomId);
|
client = testClient.client;
|
||||||
|
room = new Room(roomId);
|
||||||
client.store.storeRoom(room);
|
client.store.storeRoom(room);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
const sdk = require("../..");
|
import * as utils from "../test-utils";
|
||||||
const EventStatus = sdk.EventStatus;
|
import {EventStatus} from "../../src/models/event";
|
||||||
const HttpBackend = require("matrix-mock-request");
|
import {TestClient} from "../TestClient";
|
||||||
const utils = require("../test-utils");
|
|
||||||
|
|
||||||
describe("MatrixClient room timelines", function() {
|
describe("MatrixClient room timelines", function() {
|
||||||
const baseUrl = "http://localhost.or.something";
|
|
||||||
let client = null;
|
let client = null;
|
||||||
let httpBackend = null;
|
let httpBackend = null;
|
||||||
const userId = "@alice:localhost";
|
const userId = "@alice:localhost";
|
||||||
@@ -101,15 +100,17 @@ describe("MatrixClient room timelines", function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
httpBackend = new HttpBackend();
|
// these tests should work with or without timelineSupport
|
||||||
sdk.request(httpBackend.requestFn);
|
const testClient = new TestClient(
|
||||||
client = sdk.createClient({
|
userId,
|
||||||
baseUrl: baseUrl,
|
"DEVICE",
|
||||||
userId: userId,
|
accessToken,
|
||||||
accessToken: accessToken,
|
undefined,
|
||||||
// these tests should work with or without timelineSupport
|
{timelineSupport: true},
|
||||||
timelineSupport: true,
|
);
|
||||||
});
|
httpBackend = testClient.httpBackend;
|
||||||
|
client = testClient.client;
|
||||||
|
|
||||||
setNextSyncData();
|
setNextSyncData();
|
||||||
httpBackend.when("GET", "/pushrules").respond(200, {});
|
httpBackend.when("GET", "/pushrules").respond(200, {});
|
||||||
httpBackend.when("POST", "/filter").respond(200, { filter_id: "fid" });
|
httpBackend.when("POST", "/filter").respond(200, { filter_id: "fid" });
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
const sdk = require("../..");
|
import {MatrixEvent} from "../../src/models/event";
|
||||||
const HttpBackend = require("matrix-mock-request");
|
import {EventTimeline} from "../../src/models/event-timeline";
|
||||||
const utils = require("../test-utils");
|
import * as utils from "../test-utils";
|
||||||
const MatrixEvent = sdk.MatrixEvent;
|
import {TestClient} from "../TestClient";
|
||||||
const EventTimeline = sdk.EventTimeline;
|
|
||||||
|
|
||||||
describe("MatrixClient syncing", function() {
|
describe("MatrixClient syncing", function() {
|
||||||
const baseUrl = "http://localhost.or.something";
|
|
||||||
let client = null;
|
let client = null;
|
||||||
let httpBackend = null;
|
let httpBackend = null;
|
||||||
const selfUserId = "@alice:localhost";
|
const selfUserId = "@alice:localhost";
|
||||||
@@ -20,13 +18,9 @@ describe("MatrixClient syncing", function() {
|
|||||||
const roomTwo = "!bar:localhost";
|
const roomTwo = "!bar:localhost";
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
httpBackend = new HttpBackend();
|
const testClient = new TestClient(selfUserId, "DEVICE", selfAccessToken);
|
||||||
sdk.request(httpBackend.requestFn);
|
httpBackend = testClient.httpBackend;
|
||||||
client = sdk.createClient({
|
client = testClient.client;
|
||||||
baseUrl: baseUrl,
|
|
||||||
userId: selfUserId,
|
|
||||||
accessToken: selfAccessToken,
|
|
||||||
});
|
|
||||||
httpBackend.when("GET", "/pushrules").respond(200, {});
|
httpBackend.when("GET", "/pushrules").respond(200, {});
|
||||||
httpBackend.when("POST", "/filter").respond(200, { filter_id: "a filter id" });
|
httpBackend.when("POST", "/filter").respond(200, { filter_id: "a filter id" });
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2016 OpenMarket Ltd
|
Copyright 2016 OpenMarket Ltd
|
||||||
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -16,12 +17,11 @@ limitations under the License.
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const anotherjson = require('another-json');
|
import anotherjson from "another-json";
|
||||||
|
import * as utils from "../../src/utils";
|
||||||
const utils = require('../../lib/utils');
|
import * as testUtils from "../test-utils";
|
||||||
const testUtils = require('../test-utils');
|
import {TestClient} from "../TestClient";
|
||||||
const TestClient = require('../TestClient').default;
|
import {logger} from "../../src/logger";
|
||||||
import logger from '../../lib/logger';
|
|
||||||
|
|
||||||
const ROOM_ID = "!room:id";
|
const ROOM_ID = "!room:id";
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2017 Vector creations Ltd
|
Copyright 2017 Vector creations Ltd
|
||||||
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -14,7 +15,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import logger from '../lib/logger';
|
import {logger} from '../src/logger';
|
||||||
|
|
||||||
// try to load the olm library.
|
// try to load the olm library.
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -2,9 +2,8 @@
|
|||||||
// load olm before the sdk if possible
|
// load olm before the sdk if possible
|
||||||
import './olm-loader';
|
import './olm-loader';
|
||||||
|
|
||||||
import logger from '../lib/logger';
|
import {logger} from '../src/logger';
|
||||||
import sdk from '..';
|
import {MatrixEvent} from "../src/models/event";
|
||||||
const MatrixEvent = sdk.MatrixEvent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a promise that is resolved when the client next emits a
|
* Return a promise that is resolved when the client next emits a
|
||||||
@@ -13,7 +12,7 @@ const MatrixEvent = sdk.MatrixEvent;
|
|||||||
* @param {Number=} count Number of syncs to wait for (default 1)
|
* @param {Number=} count Number of syncs to wait for (default 1)
|
||||||
* @return {Promise} Resolves once the client has emitted a SYNCING event
|
* @return {Promise} Resolves once the client has emitted a SYNCING event
|
||||||
*/
|
*/
|
||||||
module.exports.syncPromise = function(client, count) {
|
export function syncPromise(client, count) {
|
||||||
if (count === undefined) {
|
if (count === undefined) {
|
||||||
count = 1;
|
count = 1;
|
||||||
}
|
}
|
||||||
@@ -24,7 +23,7 @@ module.exports.syncPromise = function(client, count) {
|
|||||||
const p = new Promise((resolve, reject) => {
|
const p = new Promise((resolve, reject) => {
|
||||||
const cb = (state) => {
|
const cb = (state) => {
|
||||||
logger.log(`${Date.now()} syncPromise(${count}): ${state}`);
|
logger.log(`${Date.now()} syncPromise(${count}): ${state}`);
|
||||||
if (state == 'SYNCING') {
|
if (state === 'SYNCING') {
|
||||||
resolve();
|
resolve();
|
||||||
} else {
|
} else {
|
||||||
client.once('sync', cb);
|
client.once('sync', cb);
|
||||||
@@ -34,9 +33,9 @@ module.exports.syncPromise = function(client, count) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return p.then(() => {
|
return p.then(() => {
|
||||||
return module.exports.syncPromise(client, count-1);
|
return syncPromise(client, count-1);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a spy for an object and automatically spy its methods.
|
* Create a spy for an object and automatically spy its methods.
|
||||||
@@ -44,7 +43,7 @@ module.exports.syncPromise = function(client, count) {
|
|||||||
* @param {string} name The name of the class
|
* @param {string} name The name of the class
|
||||||
* @return {Object} An instantiated object with spied methods/properties.
|
* @return {Object} An instantiated object with spied methods/properties.
|
||||||
*/
|
*/
|
||||||
module.exports.mock = function(constr, name) {
|
export function mock(constr, name) {
|
||||||
// Based on
|
// Based on
|
||||||
// http://eclipsesource.com/blogs/2014/03/27/mocks-in-jasmine-tests/
|
// http://eclipsesource.com/blogs/2014/03/27/mocks-in-jasmine-tests/
|
||||||
const HelperConstr = new Function(); // jshint ignore:line
|
const HelperConstr = new Function(); // jshint ignore:line
|
||||||
@@ -65,7 +64,7 @@ module.exports.mock = function(constr, name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an Event.
|
* Create an Event.
|
||||||
@@ -78,7 +77,7 @@ module.exports.mock = function(constr, name) {
|
|||||||
* @param {boolean} opts.event True to make a MatrixEvent.
|
* @param {boolean} opts.event True to make a MatrixEvent.
|
||||||
* @return {Object} a JSON object representing this event.
|
* @return {Object} a JSON object representing this event.
|
||||||
*/
|
*/
|
||||||
module.exports.mkEvent = function(opts) {
|
export function mkEvent(opts) {
|
||||||
if (!opts.type || !opts.content) {
|
if (!opts.type || !opts.content) {
|
||||||
throw new Error("Missing .type or .content =>" + JSON.stringify(opts));
|
throw new Error("Missing .type or .content =>" + JSON.stringify(opts));
|
||||||
}
|
}
|
||||||
@@ -97,14 +96,14 @@ module.exports.mkEvent = function(opts) {
|
|||||||
event.state_key = "";
|
event.state_key = "";
|
||||||
}
|
}
|
||||||
return opts.event ? new MatrixEvent(event) : event;
|
return opts.event ? new MatrixEvent(event) : event;
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an m.presence event.
|
* Create an m.presence event.
|
||||||
* @param {Object} opts Values for the presence.
|
* @param {Object} opts Values for the presence.
|
||||||
* @return {Object|MatrixEvent} The event
|
* @return {Object|MatrixEvent} The event
|
||||||
*/
|
*/
|
||||||
module.exports.mkPresence = function(opts) {
|
export function mkPresence(opts) {
|
||||||
if (!opts.user) {
|
if (!opts.user) {
|
||||||
throw new Error("Missing user");
|
throw new Error("Missing user");
|
||||||
}
|
}
|
||||||
@@ -120,7 +119,7 @@ module.exports.mkPresence = function(opts) {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
return opts.event ? new MatrixEvent(event) : event;
|
return opts.event ? new MatrixEvent(event) : event;
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an m.room.member event.
|
* Create an m.room.member event.
|
||||||
@@ -135,7 +134,7 @@ module.exports.mkPresence = function(opts) {
|
|||||||
* @param {boolean} opts.event True to make a MatrixEvent.
|
* @param {boolean} opts.event True to make a MatrixEvent.
|
||||||
* @return {Object|MatrixEvent} The event
|
* @return {Object|MatrixEvent} The event
|
||||||
*/
|
*/
|
||||||
module.exports.mkMembership = function(opts) {
|
export function mkMembership(opts) {
|
||||||
opts.type = "m.room.member";
|
opts.type = "m.room.member";
|
||||||
if (!opts.skey) {
|
if (!opts.skey) {
|
||||||
opts.skey = opts.sender || opts.user;
|
opts.skey = opts.sender || opts.user;
|
||||||
@@ -152,8 +151,8 @@ module.exports.mkMembership = function(opts) {
|
|||||||
if (opts.url) {
|
if (opts.url) {
|
||||||
opts.content.avatar_url = opts.url;
|
opts.content.avatar_url = opts.url;
|
||||||
}
|
}
|
||||||
return module.exports.mkEvent(opts);
|
return mkEvent(opts);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an m.room.message event.
|
* Create an m.room.message event.
|
||||||
@@ -164,7 +163,7 @@ module.exports.mkMembership = function(opts) {
|
|||||||
* @param {boolean} opts.event True to make a MatrixEvent.
|
* @param {boolean} opts.event True to make a MatrixEvent.
|
||||||
* @return {Object|MatrixEvent} The event
|
* @return {Object|MatrixEvent} The event
|
||||||
*/
|
*/
|
||||||
module.exports.mkMessage = function(opts) {
|
export function mkMessage(opts) {
|
||||||
opts.type = "m.room.message";
|
opts.type = "m.room.message";
|
||||||
if (!opts.msg) {
|
if (!opts.msg) {
|
||||||
opts.msg = "Random->" + Math.random();
|
opts.msg = "Random->" + Math.random();
|
||||||
@@ -176,8 +175,8 @@ module.exports.mkMessage = function(opts) {
|
|||||||
msgtype: "m.text",
|
msgtype: "m.text",
|
||||||
body: opts.msg,
|
body: opts.msg,
|
||||||
};
|
};
|
||||||
return module.exports.mkEvent(opts);
|
return mkEvent(opts);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -185,10 +184,10 @@ module.exports.mkMessage = function(opts) {
|
|||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
module.exports.MockStorageApi = function() {
|
export function MockStorageApi() {
|
||||||
this.data = {};
|
this.data = {};
|
||||||
};
|
}
|
||||||
module.exports.MockStorageApi.prototype = {
|
MockStorageApi.prototype = {
|
||||||
get length() {
|
get length() {
|
||||||
return Object.keys(this.data).length;
|
return Object.keys(this.data).length;
|
||||||
},
|
},
|
||||||
@@ -213,7 +212,7 @@ module.exports.MockStorageApi.prototype = {
|
|||||||
* @param {MatrixEvent} event
|
* @param {MatrixEvent} event
|
||||||
* @returns {Promise} promise which resolves (to `event`) when the event has been decrypted
|
* @returns {Promise} promise which resolves (to `event`) when the event has been decrypted
|
||||||
*/
|
*/
|
||||||
module.exports.awaitDecryption = function(event) {
|
export function awaitDecryption(event) {
|
||||||
if (!event.isBeingDecrypted()) {
|
if (!event.isBeingDecrypted()) {
|
||||||
return Promise.resolve(event);
|
return Promise.resolve(event);
|
||||||
}
|
}
|
||||||
@@ -226,19 +225,19 @@ module.exports.awaitDecryption = function(event) {
|
|||||||
resolve(ev);
|
resolve(ev);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
const HttpResponse = module.exports.HttpResponse = function(
|
export function HttpResponse(
|
||||||
httpLookups, acceptKeepalives, ignoreUnhandledSync,
|
httpLookups, acceptKeepalives, ignoreUnhandledSync,
|
||||||
) {
|
) {
|
||||||
this.httpLookups = httpLookups;
|
this.httpLookups = httpLookups;
|
||||||
this.acceptKeepalives = acceptKeepalives === undefined ? true : acceptKeepalives;
|
this.acceptKeepalives = acceptKeepalives === undefined ? true : acceptKeepalives;
|
||||||
this.ignoreUnhandledSync = ignoreUnhandledSync;
|
this.ignoreUnhandledSync = ignoreUnhandledSync;
|
||||||
this.pendingLookup = null;
|
this.pendingLookup = null;
|
||||||
};
|
}
|
||||||
|
|
||||||
HttpResponse.prototype.request = function HttpResponse(
|
HttpResponse.prototype.request = function(
|
||||||
cb, method, path, qp, data, prefix,
|
cb, method, path, qp, data, prefix,
|
||||||
) {
|
) {
|
||||||
if (path === HttpResponse.KEEP_ALIVE_PATH && this.acceptKeepalives) {
|
if (path === HttpResponse.KEEP_ALIVE_PATH && this.acceptKeepalives) {
|
||||||
@@ -351,7 +350,7 @@ HttpResponse.defaultResponses = function(userId) {
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.setHttpResponses = function setHttpResponses(
|
export function setHttpResponses(
|
||||||
client, responses, acceptKeepalives, ignoreUnhandledSyncs,
|
client, responses, acceptKeepalives, ignoreUnhandledSyncs,
|
||||||
) {
|
) {
|
||||||
const httpResponseObj = new HttpResponse(
|
const httpResponseObj = new HttpResponse(
|
||||||
@@ -367,4 +366,4 @@ module.exports.setHttpResponses = function setHttpResponses(
|
|||||||
client._http.authedRequestWithPrefix.mockImplementation(httpReq);
|
client._http.authedRequestWithPrefix.mockImplementation(httpReq);
|
||||||
client._http.requestWithPrefix.mockImplementation(httpReq);
|
client._http.requestWithPrefix.mockImplementation(httpReq);
|
||||||
client._http.request.mockImplementation(httpReq);
|
client._http.request.mockImplementation(httpReq);
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2018 New Vector Ltd
|
Copyright 2018 New Vector Ltd
|
||||||
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -16,12 +17,10 @@ limitations under the License.
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
const sdk = require("../..");
|
|
||||||
|
|
||||||
const AutoDiscovery = sdk.AutoDiscovery;
|
|
||||||
|
|
||||||
import MockHttpBackend from "matrix-mock-request";
|
import MockHttpBackend from "matrix-mock-request";
|
||||||
|
import * as sdk from "../../src";
|
||||||
|
import {AutoDiscovery} from "../../src/autodiscovery";
|
||||||
|
|
||||||
describe("AutoDiscovery", function() {
|
describe("AutoDiscovery", function() {
|
||||||
let httpBackend = null;
|
let httpBackend = null;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
const ContentRepo = require("../../lib/content-repo");
|
import * as ContentRepo from "../../src/content-repo";
|
||||||
|
|
||||||
describe("ContentRepo", function() {
|
describe("ContentRepo", function() {
|
||||||
const baseUrl = "https://my.home.server";
|
const baseUrl = "https://my.home.server";
|
||||||
|
|||||||
@@ -1,26 +1,22 @@
|
|||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
|
|
||||||
import '../olm-loader';
|
import '../olm-loader';
|
||||||
|
import {Crypto} from "../../src/crypto";
|
||||||
import Crypto from '../../lib/crypto';
|
import {WebStorageSessionStore} from "../../src/store/session/webstorage";
|
||||||
|
import {MemoryCryptoStore} from "../../src/crypto/store/memory-crypto-store";
|
||||||
import WebStorageSessionStore from '../../lib/store/session/webstorage';
|
import {MockStorageApi} from "../MockStorageApi";
|
||||||
import MemoryCryptoStore from '../../lib/crypto/store/memory-crypto-store.js';
|
import {TestClient} from "../TestClient";
|
||||||
import MockStorageApi from '../MockStorageApi';
|
import {MatrixEvent} from "../../src/models/event";
|
||||||
import TestClient from '../TestClient';
|
import {Room} from "../../src/models/room";
|
||||||
import {MatrixEvent} from '../../lib/models/event';
|
import * as olmlib from "../../src/crypto/olmlib";
|
||||||
import Room from '../../lib/models/room';
|
|
||||||
import olmlib from '../../lib/crypto/olmlib';
|
|
||||||
import {sleep} from "../../src/utils";
|
import {sleep} from "../../src/utils";
|
||||||
|
import {EventEmitter} from "events";
|
||||||
const EventEmitter = require("events").EventEmitter;
|
import {CRYPTO_ENABLED} from "../../src/client";
|
||||||
|
|
||||||
const sdk = require("../..");
|
|
||||||
|
|
||||||
const Olm = global.Olm;
|
const Olm = global.Olm;
|
||||||
|
|
||||||
describe("Crypto", function() {
|
describe("Crypto", function() {
|
||||||
if (!sdk.CRYPTO_ENABLED) {
|
if (!CRYPTO_ENABLED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2017 Vector Creations Ltd
|
Copyright 2017 Vector Creations Ltd
|
||||||
Copyright 2018, 2019 New Vector Ltd
|
Copyright 2018, 2019 New Vector Ltd
|
||||||
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -15,10 +16,10 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import DeviceList from '../../../lib/crypto/DeviceList';
|
import {logger} from "../../../src/logger";
|
||||||
import MemoryCryptoStore from '../../../lib/crypto/store/memory-crypto-store.js';
|
import * as utils from "../../../src/utils";
|
||||||
import utils from '../../../lib/utils';
|
import {MemoryCryptoStore} from "../../../src/crypto/store/memory-crypto-store";
|
||||||
import logger from '../../../lib/logger';
|
import {DeviceList} from "../../../src/crypto/DeviceList";
|
||||||
|
|
||||||
const signedDeviceList = {
|
const signedDeviceList = {
|
||||||
"failures": {},
|
"failures": {},
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
import '../../../olm-loader';
|
import '../../../olm-loader';
|
||||||
|
import * as algorithms from "../../../../src/crypto/algorithms";
|
||||||
|
import {MemoryCryptoStore} from "../../../../src/crypto/store/memory-crypto-store";
|
||||||
|
import {MockStorageApi} from "../../../MockStorageApi";
|
||||||
|
import * as testUtils from "../../../test-utils";
|
||||||
|
import {OlmDevice} from "../../../../src/crypto/OlmDevice";
|
||||||
|
import {Crypto} from "../../../../src/crypto";
|
||||||
|
import {logger} from "../../../../src/logger";
|
||||||
|
import {MatrixEvent} from "../../../../src/models/event";
|
||||||
|
|
||||||
import sdk from '../../../..';
|
|
||||||
import algorithms from '../../../../lib/crypto/algorithms';
|
|
||||||
import MemoryCryptoStore from '../../../../lib/crypto/store/memory-crypto-store.js';
|
|
||||||
import MockStorageApi from '../../../MockStorageApi';
|
|
||||||
import testUtils from '../../../test-utils';
|
|
||||||
import OlmDevice from '../../../../lib/crypto/OlmDevice';
|
|
||||||
import Crypto from '../../../../lib/crypto';
|
|
||||||
import logger from '../../../../lib/logger';
|
|
||||||
|
|
||||||
const MatrixEvent = sdk.MatrixEvent;
|
|
||||||
const MegolmDecryption = algorithms.DECRYPTION_CLASSES['m.megolm.v1.aes-sha2'];
|
const MegolmDecryption = algorithms.DECRYPTION_CLASSES['m.megolm.v1.aes-sha2'];
|
||||||
const MegolmEncryption = algorithms.ENCRYPTION_CLASSES['m.megolm.v1.aes-sha2'];
|
const MegolmEncryption = algorithms.ENCRYPTION_CLASSES['m.megolm.v1.aes-sha2'];
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2018,2019 New Vector Ltd
|
Copyright 2018,2019 New Vector Ltd
|
||||||
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -15,14 +16,12 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import '../../../olm-loader';
|
import '../../../olm-loader';
|
||||||
|
import {MemoryCryptoStore} from "../../../../src/crypto/store/memory-crypto-store";
|
||||||
import MemoryCryptoStore from '../../../../lib/crypto/store/memory-crypto-store.js';
|
import {MockStorageApi} from "../../../MockStorageApi";
|
||||||
import MockStorageApi from '../../../MockStorageApi';
|
import {logger} from "../../../../src/logger";
|
||||||
import logger from '../../../../lib/logger';
|
import {OlmDevice} from "../../../../src/crypto/OlmDevice";
|
||||||
|
import * as olmlib from "../../../../src/crypto/olmlib";
|
||||||
import OlmDevice from '../../../../lib/crypto/OlmDevice';
|
import {DeviceInfo} from "../../../../src/crypto/deviceinfo";
|
||||||
import olmlib from '../../../../lib/crypto/olmlib';
|
|
||||||
import DeviceInfo from '../../../../lib/crypto/deviceinfo';
|
|
||||||
|
|
||||||
function makeOlmDevice() {
|
function makeOlmDevice() {
|
||||||
const mockStorage = new MockStorageApi();
|
const mockStorage = new MockStorageApi();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2018 New Vector Ltd
|
Copyright 2018 New Vector Ltd
|
||||||
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -15,23 +16,20 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import '../../olm-loader';
|
import '../../olm-loader';
|
||||||
|
import {logger} from "../../../src/logger";
|
||||||
import sdk from '../../..';
|
import * as olmlib from "../../../src/crypto/olmlib";
|
||||||
import algorithms from '../../../lib/crypto/algorithms';
|
import {MatrixClient} from "../../../src/client";
|
||||||
import WebStorageSessionStore from '../../../lib/store/session/webstorage';
|
import {MatrixEvent} from "../../../src/models/event";
|
||||||
import MemoryCryptoStore from '../../../lib/crypto/store/memory-crypto-store.js';
|
import * as algorithms from "../../../src/crypto/algorithms";
|
||||||
import MockStorageApi from '../../MockStorageApi';
|
import {WebStorageSessionStore} from "../../../src/store/session/webstorage";
|
||||||
import testUtils from '../../test-utils';
|
import {MemoryCryptoStore} from "../../../src/crypto/store/memory-crypto-store";
|
||||||
|
import {MockStorageApi} from "../../MockStorageApi";
|
||||||
import OlmDevice from '../../../lib/crypto/OlmDevice';
|
import * as testUtils from "../../test-utils";
|
||||||
import Crypto from '../../../lib/crypto';
|
import {OlmDevice} from "../../../src/crypto/OlmDevice";
|
||||||
import logger from '../../../lib/logger';
|
import {Crypto} from "../../../src/crypto";
|
||||||
import olmlib from '../../../lib/crypto/olmlib';
|
|
||||||
|
|
||||||
const Olm = global.Olm;
|
const Olm = global.Olm;
|
||||||
|
|
||||||
const MatrixClient = sdk.MatrixClient;
|
|
||||||
const MatrixEvent = sdk.MatrixEvent;
|
|
||||||
const MegolmDecryption = algorithms.DECRYPTION_CLASSES['m.megolm.v1.aes-sha2'];
|
const MegolmDecryption = algorithms.DECRYPTION_CLASSES['m.megolm.v1.aes-sha2'];
|
||||||
|
|
||||||
const ROOM_ID = '!ROOM:ID';
|
const ROOM_ID = '!ROOM:ID';
|
||||||
|
|||||||
@@ -16,13 +16,9 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import '../../olm-loader';
|
import '../../olm-loader';
|
||||||
|
|
||||||
import anotherjson from 'another-json';
|
import anotherjson from 'another-json';
|
||||||
|
import * as olmlib from "../../../src/crypto/olmlib";
|
||||||
import olmlib from '../../../lib/crypto/olmlib';
|
import {TestClient} from '../../TestClient';
|
||||||
|
|
||||||
import TestClient from '../../TestClient';
|
|
||||||
|
|
||||||
import {HttpResponse, setHttpResponses} from '../../test-utils';
|
import {HttpResponse, setHttpResponses} from '../../test-utils';
|
||||||
|
|
||||||
async function makeTestClient(userInfo, options, keys) {
|
async function makeTestClient(userInfo, options, keys) {
|
||||||
|
|||||||
@@ -15,14 +15,11 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import '../../olm-loader';
|
import '../../olm-loader';
|
||||||
|
import * as olmlib from "../../../src/crypto/olmlib";
|
||||||
import { MatrixEvent } from '../../../lib/models/event';
|
import {SECRET_STORAGE_ALGORITHM_V1} from "../../../src/crypto/SecretStorage";
|
||||||
import { SECRET_STORAGE_ALGORITHM_V1 } from '../../../lib/crypto/SecretStorage';
|
import {MatrixEvent} from "../../../src/models/event";
|
||||||
|
import {TestClient} from '../../TestClient';
|
||||||
import olmlib from '../../../lib/crypto/olmlib';
|
import {makeTestClients} from './verification/util';
|
||||||
|
|
||||||
import TestClient from '../../TestClient';
|
|
||||||
import { makeTestClients } from './verification/util';
|
|
||||||
|
|
||||||
async function makeTestClient(userInfo, options) {
|
async function makeTestClient(userInfo, options) {
|
||||||
const client = (new TestClient(
|
const client = (new TestClient(
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2018-2019 New Vector Ltd
|
Copyright 2018-2019 New Vector Ltd
|
||||||
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -13,17 +14,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
import logger from '../../../../lib/logger';
|
import "../../../olm-loader";
|
||||||
|
import {logger} from "../../../../src/logger";
|
||||||
try {
|
import {DeviceInfo} from "../../../../src/crypto/deviceinfo";
|
||||||
global.Olm = require('olm');
|
import {ScanQRCode, ShowQRCode} from "../../../../src/crypto/verification/QRCode";
|
||||||
} catch (e) {
|
|
||||||
logger.warn("unable to run device verification tests: libolm not available");
|
|
||||||
}
|
|
||||||
|
|
||||||
import DeviceInfo from '../../../../lib/crypto/deviceinfo';
|
|
||||||
|
|
||||||
import {ShowQRCode, ScanQRCode} from '../../../../lib/crypto/verification/QRCode';
|
|
||||||
|
|
||||||
const Olm = global.Olm;
|
const Olm = global.Olm;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2019 New Vector Ltd
|
Copyright 2019 New Vector Ltd
|
||||||
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -13,22 +14,14 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
import logger from '../../../../lib/logger';
|
import "../../../olm-loader";
|
||||||
|
import {verificationMethods} from "../../../../src/crypto";
|
||||||
try {
|
import {logger} from "../../../../src/logger";
|
||||||
global.Olm = require('olm');
|
import {SAS} from "../../../../src/crypto/verification/SAS";
|
||||||
} catch (e) {
|
import {makeTestClients} from './util';
|
||||||
logger.warn("unable to run device verification tests: libolm not available");
|
|
||||||
}
|
|
||||||
|
|
||||||
import {verificationMethods} from '../../../../lib/crypto';
|
|
||||||
|
|
||||||
import SAS from '../../../../lib/crypto/verification/SAS';
|
|
||||||
|
|
||||||
const Olm = global.Olm;
|
const Olm = global.Olm;
|
||||||
|
|
||||||
import {makeTestClients} from './util';
|
|
||||||
|
|
||||||
describe("verification request", function() {
|
describe("verification request", function() {
|
||||||
if (!global.Olm) {
|
if (!global.Olm) {
|
||||||
logger.warn('Not running device verification unit tests: libolm not present');
|
logger.warn('Not running device verification unit tests: libolm not present');
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2018-2019 New Vector Ltd
|
Copyright 2018-2019 New Vector Ltd
|
||||||
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -13,29 +14,17 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
import logger from '../../../../lib/logger';
|
import "../../../olm-loader";
|
||||||
|
import {makeTestClients} from './util';
|
||||||
try {
|
import {MatrixEvent} from "../../../../src/models/event";
|
||||||
global.Olm = require('olm');
|
import {SAS} from "../../../../src/crypto/verification/SAS";
|
||||||
} catch (e) {
|
import {DeviceInfo} from "../../../../src/crypto/deviceinfo";
|
||||||
logger.warn("unable to run device verification tests: libolm not available");
|
import {verificationMethods} from "../../../../src/crypto";
|
||||||
}
|
import * as olmlib from "../../../../src/crypto/olmlib";
|
||||||
|
import {logger} from "../../../../src/logger";
|
||||||
import olmlib from '../../../../lib/crypto/olmlib';
|
|
||||||
|
|
||||||
import sdk from '../../../..';
|
|
||||||
|
|
||||||
import {verificationMethods} from '../../../../lib/crypto';
|
|
||||||
import DeviceInfo from '../../../../lib/crypto/deviceinfo';
|
|
||||||
|
|
||||||
import SAS from '../../../../lib/crypto/verification/SAS';
|
|
||||||
|
|
||||||
const Olm = global.Olm;
|
const Olm = global.Olm;
|
||||||
|
|
||||||
const MatrixEvent = sdk.MatrixEvent;
|
|
||||||
|
|
||||||
import {makeTestClients} from './util';
|
|
||||||
|
|
||||||
let ALICE_DEVICES;
|
let ALICE_DEVICES;
|
||||||
let BOB_DEVICES;
|
let BOB_DEVICES;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2019 New Vector Ltd
|
Copyright 2019 New Vector Ltd
|
||||||
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -14,10 +15,8 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import TestClient from '../../../TestClient';
|
import {TestClient} from '../../../TestClient';
|
||||||
|
import {MatrixEvent} from "../../../../src/models/event";
|
||||||
import sdk from '../../../..';
|
|
||||||
const MatrixEvent = sdk.MatrixEvent;
|
|
||||||
|
|
||||||
export async function makeTestClients(userInfos, options) {
|
export async function makeTestClients(userInfos, options) {
|
||||||
const clients = [];
|
const clients = [];
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
const sdk = require("../..");
|
import * as utils from "../test-utils";
|
||||||
const EventTimeline = sdk.EventTimeline;
|
import {EventTimeline} from "../../src/models/event-timeline";
|
||||||
const utils = require("../test-utils");
|
import {RoomState} from "../../src/models/room-state";
|
||||||
|
|
||||||
function mockRoomStates(timeline) {
|
function mockRoomStates(timeline) {
|
||||||
timeline._startState = utils.mock(sdk.RoomState, "startState");
|
timeline._startState = utils.mock(RoomState, "startState");
|
||||||
timeline._endState = utils.mock(sdk.RoomState, "endState");
|
timeline._endState = utils.mock(RoomState, "endState");
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("EventTimeline", function() {
|
describe("EventTimeline", function() {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2017 New Vector Ltd
|
Copyright 2017 New Vector Ltd
|
||||||
|
Copyright 2019 The Matrix.org Foundaction C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -14,10 +15,8 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import sdk from '../..';
|
import {logger} from "../../src/logger";
|
||||||
const MatrixEvent = sdk.MatrixEvent;
|
import {MatrixEvent} from "../../src/models/event";
|
||||||
|
|
||||||
import logger from '../../lib/logger';
|
|
||||||
|
|
||||||
describe("MatrixEvent", () => {
|
describe("MatrixEvent", () => {
|
||||||
describe(".attemptDecryption", () => {
|
describe(".attemptDecryption", () => {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
const sdk = require("../..");
|
import {Filter} from "../../src/filter";
|
||||||
const Filter = sdk.Filter;
|
|
||||||
|
|
||||||
describe("Filter", function() {
|
describe("Filter", function() {
|
||||||
const filterId = "f1lt3ring15g00d4ursoul";
|
const filterId = "f1lt3ring15g00d4ursoul";
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2016 OpenMarket Ltd
|
Copyright 2016 OpenMarket Ltd
|
||||||
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -16,12 +17,9 @@ limitations under the License.
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
const sdk = require("../..");
|
import {logger} from "../../src/logger";
|
||||||
|
import {InteractiveAuth} from "../../src/interactive-auth";
|
||||||
const InteractiveAuth = sdk.InteractiveAuth;
|
import {MatrixError} from "../../src/http-api";
|
||||||
const MatrixError = sdk.MatrixError;
|
|
||||||
|
|
||||||
import logger from '../../lib/logger';
|
|
||||||
|
|
||||||
// Trivial client object to test interactive auth
|
// Trivial client object to test interactive auth
|
||||||
// (we do not need TestClient here)
|
// (we do not need TestClient here)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import TestClient from '../TestClient';
|
import {TestClient} from '../TestClient';
|
||||||
|
|
||||||
describe('Login request', function() {
|
describe('Login request', function() {
|
||||||
let client;
|
let client;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
const sdk = require("../..");
|
|
||||||
const MatrixClient = sdk.MatrixClient;
|
|
||||||
|
|
||||||
import logger from '../../lib/logger';
|
import {logger} from "../../src/logger";
|
||||||
|
import {MatrixClient} from "../../src/client";
|
||||||
|
import {Filter} from "../../src/filter";
|
||||||
|
|
||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
|
|
||||||
@@ -180,7 +180,7 @@ describe("MatrixClient", function() {
|
|||||||
httpLookups.push(SYNC_RESPONSE);
|
httpLookups.push(SYNC_RESPONSE);
|
||||||
const filterId = "ehfewf";
|
const filterId = "ehfewf";
|
||||||
store.getFilterIdByName.mockReturnValue(filterId);
|
store.getFilterIdByName.mockReturnValue(filterId);
|
||||||
const filter = new sdk.Filter(0, filterId);
|
const filter = new Filter(0, filterId);
|
||||||
filter.setDefinition({"room": {"timeline": {"limit": 8}}});
|
filter.setDefinition({"room": {"timeline": {"limit": 8}}});
|
||||||
store.getFilter.mockReturnValue(filter);
|
store.getFilter.mockReturnValue(filter);
|
||||||
const syncPromise = new Promise((resolve, reject) => {
|
const syncPromise = new Promise((resolve, reject) => {
|
||||||
@@ -247,7 +247,7 @@ describe("MatrixClient", function() {
|
|||||||
|
|
||||||
const filterName = getFilterName(client.credentials.userId);
|
const filterName = getFilterName(client.credentials.userId);
|
||||||
client.store.setFilterIdByName(filterName, invalidFilterId);
|
client.store.setFilterIdByName(filterName, invalidFilterId);
|
||||||
const filter = new sdk.Filter(client.credentials.userId);
|
const filter = new Filter(client.credentials.userId);
|
||||||
|
|
||||||
client.getOrCreateFilter(filterName, filter).then(function(filterId) {
|
client.getOrCreateFilter(filterName, filter).then(function(filterId) {
|
||||||
expect(filterId).toEqual(FILTER_RESPONSE.data.filter_id);
|
expect(filterId).toEqual(FILTER_RESPONSE.data.filter_id);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
const PushProcessor = require("../../lib/pushprocessor");
|
import * as utils from "../test-utils";
|
||||||
const utils = require("../test-utils");
|
import {PushProcessor} from "../../src/pushprocessor";
|
||||||
|
|
||||||
describe('NotificationService', function() {
|
describe('NotificationService', function() {
|
||||||
const testUserId = "@ali:matrix.org";
|
const testUserId = "@ali:matrix.org";
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
const callbacks = require("../../src/realtime-callbacks");
|
import * as callbacks from "../../src/realtime-callbacks";
|
||||||
|
|
||||||
let wallTime = 1234567890;
|
let wallTime = 1234567890;
|
||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
const sdk = require("../..");
|
import * as utils from "../test-utils";
|
||||||
const RoomMember = sdk.RoomMember;
|
import {RoomMember} from "../../src/models/room-member";
|
||||||
const utils = require("../test-utils");
|
|
||||||
|
|
||||||
describe("RoomMember", function() {
|
describe("RoomMember", function() {
|
||||||
const roomId = "!foo:bar";
|
const roomId = "!foo:bar";
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
const sdk = require("../..");
|
import * as utils from "../test-utils";
|
||||||
const RoomState = sdk.RoomState;
|
import {RoomState} from "../../src/models/room-state";
|
||||||
const RoomMember = sdk.RoomMember;
|
import {RoomMember} from "../../src/models/room-member";
|
||||||
const utils = require("../test-utils");
|
|
||||||
|
|
||||||
describe("RoomState", function() {
|
describe("RoomState", function() {
|
||||||
const roomId = "!foo:bar";
|
const roomId = "!foo:bar";
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
const sdk = require("../..");
|
import * as utils from "../test-utils";
|
||||||
const Room = sdk.Room;
|
import {EventStatus, MatrixEvent} from "../../src/models/event";
|
||||||
const RoomState = sdk.RoomState;
|
import {EventTimeline} from "../../src/models/event-timeline";
|
||||||
const MatrixEvent = sdk.MatrixEvent;
|
import {RoomState} from "../../src/models/room-state";
|
||||||
const EventStatus = sdk.EventStatus;
|
import {Room} from "../../src/models/room";
|
||||||
const EventTimeline = sdk.EventTimeline;
|
|
||||||
const utils = require("../test-utils");
|
|
||||||
|
|
||||||
describe("Room", function() {
|
describe("Room", function() {
|
||||||
const roomId = "!foo:bar";
|
const roomId = "!foo:bar";
|
||||||
@@ -20,9 +18,9 @@ describe("Room", function() {
|
|||||||
room = new Room(roomId);
|
room = new Room(roomId);
|
||||||
// mock RoomStates
|
// mock RoomStates
|
||||||
room.oldState = room.getLiveTimeline()._startState =
|
room.oldState = room.getLiveTimeline()._startState =
|
||||||
utils.mock(sdk.RoomState, "oldState");
|
utils.mock(RoomState, "oldState");
|
||||||
room.currentState = room.getLiveTimeline()._endState =
|
room.currentState = room.getLiveTimeline()._endState =
|
||||||
utils.mock(sdk.RoomState, "currentState");
|
utils.mock(RoomState, "currentState");
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("getAvatarUrl", function() {
|
describe("getAvatarUrl", function() {
|
||||||
|
|||||||
@@ -3,10 +3,9 @@
|
|||||||
|
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
import {defer} from '../../src/utils';
|
import {defer} from '../../src/utils';
|
||||||
const sdk = require("../..");
|
import {MatrixError} from "../../src/http-api";
|
||||||
const MatrixScheduler = sdk.MatrixScheduler;
|
import {MatrixScheduler} from "../../src/scheduler";
|
||||||
const MatrixError = sdk.MatrixError;
|
import * as utils from "../test-utils";
|
||||||
const utils = require("../test-utils");
|
|
||||||
|
|
||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2017 Vector Creations Ltd
|
Copyright 2017 Vector Creations Ltd
|
||||||
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -16,9 +17,8 @@ limitations under the License.
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
import sdk from "../..";
|
|
||||||
|
|
||||||
const SyncAccumulator = sdk.SyncAccumulator;
|
import {SyncAccumulator} from "../../src/sync-accumulator";
|
||||||
|
|
||||||
describe("SyncAccumulator", function() {
|
describe("SyncAccumulator", function() {
|
||||||
let sa;
|
let sa;
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
const sdk = require("../..");
|
import {EventTimeline} from "../../src/models/event-timeline";
|
||||||
const EventTimeline = sdk.EventTimeline;
|
import {TimelineIndex, TimelineWindow} from "../../src/timeline-window";
|
||||||
const TimelineWindow = sdk.TimelineWindow;
|
import * as utils from "../test-utils";
|
||||||
const TimelineIndex = require("../../lib/timeline-window").TimelineIndex;
|
|
||||||
|
|
||||||
const utils = require("../test-utils");
|
|
||||||
|
|
||||||
const ROOM_ID = "roomId";
|
const ROOM_ID = "roomId";
|
||||||
const USER_ID = "userId";
|
const USER_ID = "userId";
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
const sdk = require("../..");
|
import {User} from "../../src/models/user";
|
||||||
const User = sdk.User;
|
import * as utils from "../test-utils";
|
||||||
const utils = require("../test-utils");
|
|
||||||
|
|
||||||
describe("User", function() {
|
describe("User", function() {
|
||||||
const userId = "@alice:bar";
|
const userId = "@alice:bar";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
const utils = require("../../lib/utils");
|
import * as utils from "../../src/utils";
|
||||||
|
|
||||||
describe("utils", function() {
|
describe("utils", function() {
|
||||||
describe("encodeParams", function() {
|
describe("encodeParams", function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user