Skip to content

Commit 0a209fc

Browse files
committed
Use promises in tests properly
1 parent eac6c46 commit 0a209fc

1 file changed

Lines changed: 24 additions & 24 deletions

File tree

‎test/app-tests/loading.js‎

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,10 @@ describe('loading:', function() {
213213
}
214214

215215
describe("Clean load with no stored credentials:", function() {
216-
it('gives a welcome page by default', function(done) {
216+
it('gives a welcome page by default', function() {
217217
loadApp();
218218

219-
sleep(1).then(() => {
219+
return sleep(1).then(() => {
220220
// at this point, we're trying to do a guest registration;
221221
// we expect a spinner
222222
assertAtLoadingSpinner(matrixChat);
@@ -231,10 +231,10 @@ describe('loading:', function() {
231231
return awaitWelcomeComponent(matrixChat);
232232
}).then(() => {
233233
expect(windowLocation.hash).toEqual("#/welcome");
234-
}).then(done, done);
234+
});
235235
});
236236

237-
it('should follow the original link after successful login', function(done) {
237+
it('should follow the original link after successful login', function() {
238238
loadApp({
239239
uriFragment: "#/room/!room:id",
240240
});
@@ -243,7 +243,7 @@ describe('loading:', function() {
243243
httpBackend.when("GET", "/versions").respond(200, {versions: ["r0.4.0"]});
244244
httpBackend.when("GET", "/api/v1").respond(200, {});
245245

246-
sleep(1).then(() => {
246+
return sleep(1).then(() => {
247247
// at this point, we're trying to do a guest registration;
248248
// we expect a spinner
249249
assertAtLoadingSpinner(matrixChat);
@@ -272,7 +272,7 @@ describe('loading:', function() {
272272
expect(localStorage.getItem('mx_access_token')).toEqual('access_token');
273273
expect(localStorage.getItem('mx_hs_url')).toEqual(DEFAULT_HS_URL);
274274
expect(localStorage.getItem('mx_is_url')).toEqual(DEFAULT_IS_URL);
275-
}).then(done, done);
275+
});
276276
});
277277

278278
it('should not register as a guest when using a #/login link', function() {
@@ -348,15 +348,15 @@ describe('loading:', function() {
348348
});
349349
});
350350

351-
it('shows a home page by default if we have no joined rooms', function(done) {
351+
it('shows a home page by default if we have no joined rooms', function() {
352352
localStorage.removeItem("mx_last_room_id");
353353

354354
httpBackend.when('GET', '/pushrules').respond(200, {});
355355
httpBackend.when('POST', '/filter').respond(200, { filter_id: 'fid' });
356356

357357
loadApp();
358358

359-
awaitLoggedIn(matrixChat).then(() => {
359+
return awaitLoggedIn(matrixChat).then(() => {
360360
// we are logged in - let the sync complete
361361
return expectAndAwaitSync();
362362
}).then(() => {
@@ -365,18 +365,18 @@ describe('loading:', function() {
365365
ReactTestUtils.findRenderedComponentWithType(
366366
matrixChat, sdk.getComponent('structures.EmbeddedPage'));
367367
expect(windowLocation.hash).toEqual("#/home");
368-
}).then(done, done);
368+
});
369369
});
370370

371-
it('shows a room view if we followed a room link', function(done) {
371+
it('shows a room view if we followed a room link', function() {
372372
httpBackend.when('GET', '/pushrules').respond(200, {});
373373
httpBackend.when('POST', '/filter').respond(200, { filter_id: 'fid' });
374374

375375
loadApp({
376376
uriFragment: "#/room/!room:id",
377377
});
378378

379-
awaitLoggedIn(matrixChat).then(() => {
379+
return awaitLoggedIn(matrixChat).then(() => {
380380
// we are logged in - let the sync complete
381381
return expectAndAwaitSync();
382382
}).then(() => {
@@ -385,7 +385,7 @@ describe('loading:', function() {
385385
}).then(() => {
386386
httpBackend.verifyNoOutstandingExpectation();
387387
expect(windowLocation.hash).toEqual("#/room/!room:id");
388-
}).then(done, done);
388+
});
389389
});
390390

391391
describe('/#/login link:', function() {
@@ -442,10 +442,10 @@ describe('loading:', function() {
442442
});
443443

444444
describe('Guest auto-registration:', function() {
445-
it('shows a welcome page by default', function(done) {
445+
it('shows a welcome page by default', function() {
446446
loadApp();
447447

448-
sleep(1).then(() => {
448+
return sleep(1).then(() => {
449449
// at this point, we're trying to do a guest registration;
450450
// we expect a spinner
451451
assertAtLoadingSpinner(matrixChat);
@@ -469,13 +469,13 @@ describe('loading:', function() {
469469
ReactTestUtils.findRenderedComponentWithType(
470470
matrixChat, sdk.getComponent('auth.Welcome'));
471471
expect(windowLocation.hash).toEqual("#/welcome");
472-
}).then(done, done);
472+
});
473473
});
474474

475-
it('uses the default homeserver to register with', function(done) {
475+
it('uses the default homeserver to register with', function() {
476476
loadApp();
477477

478-
sleep(1).then(() => {
478+
return sleep(1).then(() => {
479479
// at this point, we're trying to do a guest registration;
480480
// we expect a spinner
481481
assertAtLoadingSpinner(matrixChat);
@@ -503,14 +503,14 @@ describe('loading:', function() {
503503
expect(windowLocation.hash).toEqual("#/welcome");
504504
expect(MatrixClientPeg.get().baseUrl).toEqual(DEFAULT_HS_URL);
505505
expect(MatrixClientPeg.get().idBaseUrl).toEqual(DEFAULT_IS_URL);
506-
}).then(done, done);
506+
});
507507
});
508508

509-
it('shows a room view if we followed a room link', function(done) {
509+
it('shows a room view if we followed a room link', function() {
510510
loadApp({
511511
uriFragment: "#/room/!room:id",
512512
});
513-
sleep(1).then(() => {
513+
return sleep(1).then(() => {
514514
// at this point, we're trying to do a guest registration;
515515
// we expect a spinner
516516
assertAtLoadingSpinner(matrixChat);
@@ -533,7 +533,7 @@ describe('loading:', function() {
533533
}).then(() => {
534534
httpBackend.verifyNoOutstandingExpectation();
535535
expect(windowLocation.hash).toEqual("#/room/!room:id");
536-
}).then(done, done);
536+
});
537537
});
538538

539539
describe('Login as user', function() {
@@ -611,12 +611,12 @@ describe('loading:', function() {
611611
});
612612

613613
describe('Token login:', function() {
614-
it('logs in successfully', function(done) {
614+
it('logs in successfully', function() {
615615
loadApp({
616616
queryString: "?loginToken=secretToken&homeserver=https%3A%2F%2Fhomeserver&identityServer=https%3A%2F%2Fidserver",
617617
});
618618

619-
sleep(1).then(() => {
619+
return sleep(1).then(() => {
620620
// we expect a spinner while we're logging in
621621
assertAtLoadingSpinner(matrixChat);
622622

@@ -645,7 +645,7 @@ describe('loading:', function() {
645645
expect(localStorage.getItem('mx_access_token')).toEqual('access_token');
646646
expect(localStorage.getItem('mx_hs_url')).toEqual('https://homeserver');
647647
expect(localStorage.getItem('mx_is_url')).toEqual('https://idserver');
648-
}).then(done, done);
648+
});
649649
});
650650
});
651651

0 commit comments

Comments
 (0)