You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2026-01-03 23:22:30 +03:00
utils.failTest -> nodeify
Automated replacement of utils.failTest with nodeify
This was done with the perl incantation:
```
find spec -name '*.js' |
xargs perl -i -pe 's/catch\((testUtils|utils).failTest\).done\(done\)/nodeify(done)/'
```
more auto
This commit is contained in:
@@ -414,7 +414,7 @@ describe("MatrixClient crypto", function() {
|
||||
q()
|
||||
.then(bobUploadsDeviceKeys)
|
||||
.then(aliDownloadsKeys)
|
||||
.catch(testUtils.failTest).done(done);
|
||||
.nodeify(done);
|
||||
});
|
||||
|
||||
it("Ali gets keys with an invalid signature", function(done) {
|
||||
@@ -433,7 +433,7 @@ describe("MatrixClient crypto", function() {
|
||||
// should get an empty list
|
||||
expect(aliTestClient.client.listDeviceKeys(bobUserId)).toEqual([]);
|
||||
})
|
||||
.catch(testUtils.failTest).done(done);
|
||||
.nodeify(done);
|
||||
});
|
||||
|
||||
it("Ali gets keys with an incorrect userId", function(done) {
|
||||
@@ -472,7 +472,7 @@ describe("MatrixClient crypto", function() {
|
||||
// should get an empty list
|
||||
expect(aliTestClient.client.listDeviceKeys(bobUserId)).toEqual([]);
|
||||
expect(aliTestClient.client.listDeviceKeys(eveUserId)).toEqual([]);
|
||||
}).catch(testUtils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
});
|
||||
|
||||
it("Ali gets keys with an incorrect deviceId", function(done) {
|
||||
@@ -508,7 +508,7 @@ describe("MatrixClient crypto", function() {
|
||||
).then(function() {
|
||||
// should get an empty list
|
||||
expect(aliTestClient.client.listDeviceKeys(bobUserId)).toEqual([]);
|
||||
}).catch(testUtils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
});
|
||||
|
||||
|
||||
@@ -540,7 +540,7 @@ describe("MatrixClient crypto", function() {
|
||||
.then(aliEnablesEncryption)
|
||||
.then(aliSendsFirstMessage)
|
||||
.then(bobRecvMessage)
|
||||
.catch(testUtils.failTest).done(done);
|
||||
.nodeify(done);
|
||||
});
|
||||
|
||||
it("Bob receives a message with a bogus sender", function(done) {
|
||||
@@ -597,7 +597,7 @@ describe("MatrixClient crypto", function() {
|
||||
bobTestClient.httpBackend.flush();
|
||||
return deferred.promise;
|
||||
})
|
||||
.catch(testUtils.failTest).done(done);
|
||||
.nodeify(done);
|
||||
});
|
||||
|
||||
it("Ali blocks Bob's device", function(done) {
|
||||
@@ -629,7 +629,7 @@ describe("MatrixClient crypto", function() {
|
||||
.then(bobRecvMessage)
|
||||
.then(aliSendsMessage)
|
||||
.then(bobRecvMessage)
|
||||
.catch(testUtils.failTest).done(done);
|
||||
.nodeify(done);
|
||||
});
|
||||
|
||||
it("Bob replies to the message", function() {
|
||||
|
||||
@@ -127,7 +127,7 @@ describe("getEventTimeline support", function() {
|
||||
expect(function() {
|
||||
client.getEventTimeline(timelineSet, "event");
|
||||
}).toThrow();
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
});
|
||||
|
||||
it("timeline support works when enabled", function(done) {
|
||||
@@ -145,7 +145,7 @@ describe("getEventTimeline support", function() {
|
||||
expect(function() {
|
||||
client.getEventTimeline(timelineSet, "event");
|
||||
}).toNotThrow();
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
|
||||
httpBackend.flush().catch(utils.failTest);
|
||||
});
|
||||
@@ -220,7 +220,7 @@ describe("getEventTimeline support", function() {
|
||||
expect(room.timeline[0].event).toEqual(EVENTS[0]);
|
||||
expect(room.timeline[1].event).toEqual(EVENTS[1]);
|
||||
expect(room.oldState.paginationToken).toEqual("pagin_end");
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -279,7 +279,7 @@ describe("MatrixClient event timelines", function() {
|
||||
.toEqual("start_token");
|
||||
expect(tl.getPaginationToken(EventTimeline.FORWARDS))
|
||||
.toEqual("end_token");
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
|
||||
httpBackend.flush().catch(utils.failTest);
|
||||
});
|
||||
@@ -311,7 +311,7 @@ describe("MatrixClient event timelines", function() {
|
||||
expect(tl.getEvents()[1].sender.name).toEqual(userName);
|
||||
expect(tl.getPaginationToken(EventTimeline.BACKWARDS)).toEqual("f_1_1");
|
||||
// expect(tl.getPaginationToken(EventTimeline.FORWARDS)).toEqual("s_5_4");
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
|
||||
httpBackend.flush().catch(utils.failTest);
|
||||
});
|
||||
@@ -460,7 +460,7 @@ describe("MatrixClient event timelines", function() {
|
||||
.toBe(null);
|
||||
expect(tl3.getPaginationToken(EventTimeline.FORWARDS))
|
||||
.toEqual("end_token3");
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
|
||||
httpBackend.flush().catch(utils.failTest);
|
||||
});
|
||||
@@ -487,7 +487,7 @@ describe("MatrixClient event timelines", function() {
|
||||
expect(true).toBeFalsy();
|
||||
}).catch(function(e) {
|
||||
expect(String(e)).toMatch(/'event'/);
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
|
||||
httpBackend.flush().catch(utils.failTest);
|
||||
});
|
||||
@@ -539,7 +539,7 @@ describe("MatrixClient event timelines", function() {
|
||||
.toEqual("start_token1");
|
||||
expect(tl.getPaginationToken(EventTimeline.FORWARDS))
|
||||
.toEqual("end_token0");
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
|
||||
httpBackend.flush().catch(utils.failTest);
|
||||
});
|
||||
@@ -591,7 +591,7 @@ describe("MatrixClient event timelines", function() {
|
||||
.toEqual("start_token0");
|
||||
expect(tl.getPaginationToken(EventTimeline.FORWARDS))
|
||||
.toEqual("end_token1");
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
|
||||
httpBackend.flush().catch(utils.failTest);
|
||||
});
|
||||
@@ -650,7 +650,7 @@ describe("MatrixClient event timelines", function() {
|
||||
}).then(function(tl) {
|
||||
expect(tl.getEvents().length).toEqual(2);
|
||||
expect(tl.getEvents()[1].event).toEqual(event);
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
|
||||
httpBackend.flush("/send/m.room.message/" + TXN_ID, 1).catch(utils.failTest);
|
||||
});
|
||||
@@ -669,7 +669,7 @@ describe("MatrixClient event timelines", function() {
|
||||
console.log("getEventTimeline completed (2)");
|
||||
expect(tl.getEvents().length).toEqual(2);
|
||||
expect(tl.getEvents()[1].getContent().body).toEqual("a body");
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
|
||||
q.all([
|
||||
httpBackend.flush("/sync", 1),
|
||||
@@ -750,6 +750,6 @@ describe("MatrixClient event timelines", function() {
|
||||
const room = client.getRoom(roomId);
|
||||
const tl = room.getLiveTimeline();
|
||||
expect(tl.getEvents().length).toEqual(1);
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -79,7 +79,7 @@ describe("MatrixClient", function() {
|
||||
|
||||
const uploads = client.getCurrentUploads();
|
||||
expect(uploads.length).toEqual(0);
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
|
||||
httpBackend.flush();
|
||||
});
|
||||
@@ -99,7 +99,7 @@ describe("MatrixClient", function() {
|
||||
rawResponse: false,
|
||||
}).then(function(response) {
|
||||
expect(response.content_uri).toEqual("uri");
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
|
||||
httpBackend.flush();
|
||||
});
|
||||
@@ -125,7 +125,7 @@ describe("MatrixClient", function() {
|
||||
expect(error.httpStatus).toEqual(400);
|
||||
expect(error.errcode).toEqual("M_SNAFU");
|
||||
expect(error.message).toEqual("broken");
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
|
||||
httpBackend.flush();
|
||||
});
|
||||
@@ -149,7 +149,7 @@ describe("MatrixClient", function() {
|
||||
|
||||
const uploads = client.getCurrentUploads();
|
||||
expect(uploads.length).toEqual(0);
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
|
||||
const r = client.cancelUpload(prom);
|
||||
expect(r).toBe(true);
|
||||
@@ -381,7 +381,7 @@ describe("MatrixClient", function() {
|
||||
algorithms: ["2"],
|
||||
unsigned: { "ghi": "def" },
|
||||
});
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
|
||||
httpBackend.flush();
|
||||
});
|
||||
@@ -398,7 +398,7 @@ describe("MatrixClient", function() {
|
||||
|
||||
client.deleteDevice(
|
||||
"my_device", auth,
|
||||
).catch(utils.failTest).done(done);
|
||||
).nodeify(done);
|
||||
|
||||
httpBackend.flush();
|
||||
});
|
||||
|
||||
@@ -94,7 +94,7 @@ describe("MatrixClient retrying", function() {
|
||||
client.cancelPendingEvent(ev1);
|
||||
expect(ev1.status).toEqual(EventStatus.CANCELLED);
|
||||
expect(tl.length).toEqual(0);
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
});
|
||||
|
||||
describe("resending", function() {
|
||||
|
||||
@@ -202,7 +202,7 @@ module.exports.mkMessage = function(opts) {
|
||||
* it("should not throw", function(done) {
|
||||
* asynchronousMethod().then(function() {
|
||||
* // some tests
|
||||
* }).catch(utils.failTest).done(done);
|
||||
* }).nodeify(done);
|
||||
* });
|
||||
*/
|
||||
module.exports.failTest = function(err) {
|
||||
|
||||
@@ -88,7 +88,7 @@ describe("InteractiveAuth", function() {
|
||||
expect(res).toBe(requestRes);
|
||||
expect(doRequest.calls.length).toEqual(1);
|
||||
expect(stateUpdated.calls.length).toEqual(1);
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
});
|
||||
|
||||
it("should make a request if no authdata is provided", function(done) {
|
||||
@@ -151,6 +151,6 @@ describe("InteractiveAuth", function() {
|
||||
expect(res).toBe(requestRes);
|
||||
expect(doRequest.calls.length).toEqual(2);
|
||||
expect(stateUpdated.calls.length).toEqual(1);
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -179,7 +179,7 @@ describe("TimelineWindow", function() {
|
||||
timelineWindow.load(undefined, 2).then(function() {
|
||||
const expectedEvents = liveTimeline.getEvents().slice(1);
|
||||
expect(timelineWindow.getEvents()).toEqual(expectedEvents);
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
});
|
||||
|
||||
it("should initialise from a specific event", function(done) {
|
||||
@@ -198,7 +198,7 @@ describe("TimelineWindow", function() {
|
||||
timelineWindow.load(eventId, 3).then(function() {
|
||||
const expectedEvents = timeline.getEvents();
|
||||
expect(timelineWindow.getEvents()).toEqual(expectedEvents);
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
});
|
||||
|
||||
it("canPaginate should return false until load has returned",
|
||||
@@ -229,7 +229,7 @@ describe("TimelineWindow", function() {
|
||||
.toBe(true);
|
||||
expect(timelineWindow.canPaginate(EventTimeline.FORWARDS))
|
||||
.toBe(true);
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -277,7 +277,7 @@ describe("TimelineWindow", function() {
|
||||
return timelineWindow.paginate(EventTimeline.BACKWARDS, 2);
|
||||
}).then(function(success) {
|
||||
expect(success).toBe(false);
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
});
|
||||
|
||||
it("should advance into next timeline", function(done) {
|
||||
@@ -322,7 +322,7 @@ describe("TimelineWindow", function() {
|
||||
return timelineWindow.paginate(EventTimeline.FORWARDS, 2);
|
||||
}).then(function(success) {
|
||||
expect(success).toBe(false);
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
});
|
||||
|
||||
it("should retreat into previous timeline", function(done) {
|
||||
@@ -367,7 +367,7 @@ describe("TimelineWindow", function() {
|
||||
return timelineWindow.paginate(EventTimeline.BACKWARDS, 2);
|
||||
}).then(function(success) {
|
||||
expect(success).toBe(false);
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
});
|
||||
|
||||
it("should make forward pagination requests", function(done) {
|
||||
@@ -399,7 +399,7 @@ describe("TimelineWindow", function() {
|
||||
expect(success).toBe(true);
|
||||
const expectedEvents = timeline.getEvents().slice(0, 5);
|
||||
expect(timelineWindow.getEvents()).toEqual(expectedEvents);
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
});
|
||||
|
||||
|
||||
@@ -432,7 +432,7 @@ describe("TimelineWindow", function() {
|
||||
expect(success).toBe(true);
|
||||
const expectedEvents = timeline.getEvents().slice(1, 6);
|
||||
expect(timelineWindow.getEvents()).toEqual(expectedEvents);
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
});
|
||||
|
||||
it("should limit the number of unsuccessful pagination requests",
|
||||
@@ -471,7 +471,7 @@ describe("TimelineWindow", function() {
|
||||
.toBe(false);
|
||||
expect(timelineWindow.canPaginate(EventTimeline.FORWARDS))
|
||||
.toBe(true);
|
||||
}).catch(utils.failTest).done(done);
|
||||
}).nodeify(done);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user