1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-07-31 15:24:23 +03:00

Apply prettier formatting

This commit is contained in:
Michael Weimann
2022-12-09 09:38:20 +01:00
parent 08a9073bd5
commit 349c2c2587
239 changed files with 22004 additions and 21928 deletions

View File

@ -20,7 +20,7 @@ import { EventStatus, RoomEvent, MatrixClient, MatrixScheduler } from "../../src
import { Room } from "../../src/models/room";
import { TestClient } from "../TestClient";
describe("MatrixClient retrying", function() {
describe("MatrixClient retrying", function () {
const userId = "@alice:localhost";
const accessToken = "aseukfgwef";
const roomId = "!room:here";
@ -30,13 +30,7 @@ describe("MatrixClient retrying", function() {
const setupTests = (): [MatrixClient, HttpBackend, Room] => {
const scheduler = new MatrixScheduler();
const testClient = new TestClient(
userId,
"DEVICE",
accessToken,
undefined,
{ scheduler },
);
const testClient = new TestClient(userId, "DEVICE", accessToken, undefined, { scheduler });
const httpBackend = testClient.httpBackend;
const client = testClient.client;
const room = new Room(roomId, client, userId);
@ -45,49 +39,46 @@ describe("MatrixClient retrying", function() {
return [client, httpBackend, room];
};
beforeEach(function() {
beforeEach(function () {
[client, httpBackend, room] = setupTests();
});
afterEach(function() {
afterEach(function () {
httpBackend!.verifyNoOutstandingExpectation();
return httpBackend!.stop();
});
xit("should retry according to MatrixScheduler.retryFn", function() {
xit("should retry according to MatrixScheduler.retryFn", function () {});
});
xit("should queue according to MatrixScheduler.queueFn", function () {});
xit("should queue according to MatrixScheduler.queueFn", function() {
xit("should mark events as EventStatus.NOT_SENT when giving up", function () {});
});
xit("should mark events as EventStatus.QUEUED when queued", function () {});
xit("should mark events as EventStatus.NOT_SENT when giving up", function() {
});
xit("should mark events as EventStatus.QUEUED when queued", function() {
});
it("should mark events as EventStatus.CANCELLED when cancelled", function() {
it("should mark events as EventStatus.CANCELLED when cancelled", function () {
// send a couple of events; the second will be queued
const p1 = client!.sendMessage(roomId, {
"msgtype": "m.text",
"body": "m1",
}).then(function() {
// we expect the first message to fail
throw new Error('Message 1 unexpectedly sent successfully');
}, () => {
// this is expected
});
const p1 = client!
.sendMessage(roomId, {
msgtype: "m.text",
body: "m1",
})
.then(
function () {
// we expect the first message to fail
throw new Error("Message 1 unexpectedly sent successfully");
},
() => {
// this is expected
},
);
// XXX: it turns out that the promise returned by this message
// never gets resolved.
// https://github.com/matrix-org/matrix-js-sdk/issues/496
client!.sendMessage(roomId, {
"msgtype": "m.text",
"body": "m2",
msgtype: "m.text",
body: "m2",
});
// both events should be in the timeline at this point
@ -100,20 +91,23 @@ describe("MatrixClient retrying", function() {
expect(ev2.status).toEqual(EventStatus.SENDING);
// the first message should get sent, and the second should get queued
httpBackend!.when("PUT", "/send/m.room.message/").check(function() {
// ev2 should now have been queued
expect(ev2.status).toEqual(EventStatus.QUEUED);
httpBackend!
.when("PUT", "/send/m.room.message/")
.check(function () {
// ev2 should now have been queued
expect(ev2.status).toEqual(EventStatus.QUEUED);
// now we can cancel the second and check everything looks sane
client!.cancelPendingEvent(ev2);
expect(ev2.status).toEqual(EventStatus.CANCELLED);
expect(tl.length).toEqual(1);
// now we can cancel the second and check everything looks sane
client!.cancelPendingEvent(ev2);
expect(ev2.status).toEqual(EventStatus.CANCELLED);
expect(tl.length).toEqual(1);
// shouldn't be able to cancel the first message yet
expect(function() {
client!.cancelPendingEvent(ev1);
}).toThrow();
}).respond(400); // fail the first message
// shouldn't be able to cancel the first message yet
expect(function () {
client!.cancelPendingEvent(ev1);
}).toThrow();
})
.respond(400); // fail the first message
// wait for the localecho of ev1 to be updated
const p3 = new Promise<void>((resolve, reject) => {
@ -122,7 +116,7 @@ describe("MatrixClient retrying", function() {
resolve();
}
});
}).then(function() {
}).then(function () {
expect(ev1.status).toEqual(EventStatus.NOT_SENT);
expect(tl.length).toEqual(1);
@ -132,19 +126,11 @@ describe("MatrixClient retrying", function() {
expect(tl.length).toEqual(0);
});
return Promise.all([
p1,
p3,
httpBackend!.flushAllExpected(),
]);
return Promise.all([p1, p3, httpBackend!.flushAllExpected()]);
});
describe("resending", function() {
xit("should be able to resend a NOT_SENT event", function() {
});
xit("should be able to resend a sent event", function() {
});
describe("resending", function () {
xit("should be able to resend a NOT_SENT event", function () {});
xit("should be able to resend a sent event", function () {});
});
});