@@ -25,7 +25,6 @@ import React from 'react';
2525import ReactDOM from 'react-dom' ;
2626import ReactTestUtils from 'react-dom/test-utils' ;
2727import expect from 'expect' ;
28- import Promise from 'bluebird' ;
2928import MatrixReactTestUtils from 'matrix-react-test-utils' ;
3029
3130import jssdk from 'matrix-js-sdk' ;
@@ -41,6 +40,7 @@ import MockHttpBackend from 'matrix-mock-request';
4140import { parseQs , parseQsFromFragment } from '../../src/vector/url_utils' ;
4241import { makeType } from "matrix-react-sdk/lib/utils/TypeUtils" ;
4342import { ValidatedServerConfig } from "matrix-react-sdk/lib/utils/AutoDiscoveryUtils" ;
43+ import { sleep } from "../test-utils" ;
4444
4545const DEFAULT_HS_URL = 'http://my_server' ;
4646const DEFAULT_IS_URL = 'http://my_is' ;
@@ -216,7 +216,7 @@ describe('loading:', function() {
216216 it ( 'gives a welcome page by default' , function ( done ) {
217217 loadApp ( ) ;
218218
219- Promise . delay ( 1 ) . then ( ( ) => {
219+ sleep ( 1 ) . then ( ( ) => {
220220 // at this point, we're trying to do a guest registration;
221221 // we expect a spinner
222222 assertAtLoadingSpinner ( matrixChat ) ;
@@ -231,7 +231,7 @@ describe('loading:', function() {
231231 return awaitWelcomeComponent ( matrixChat ) ;
232232 } ) . then ( ( ) => {
233233 expect ( windowLocation . hash ) . toEqual ( "#/welcome" ) ;
234- } ) . done ( done , done ) ;
234+ } ) . then ( done , done ) ;
235235 } ) ;
236236
237237 it ( 'should follow the original link after successful login' , function ( done ) {
@@ -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- Promise . delay ( 1 ) . then ( ( ) => {
246+ sleep ( 1 ) . then ( ( ) => {
247247 // at this point, we're trying to do a guest registration;
248248 // we expect a spinner
249249 assertAtLoadingSpinner ( matrixChat ) ;
@@ -255,7 +255,7 @@ describe('loading:', function() {
255255 return httpBackend . flush ( ) ;
256256 } ) . then ( ( ) => {
257257 // Wait for another trip around the event loop for the UI to update
258- return Promise . delay ( 10 ) ;
258+ return sleep ( 10 ) ;
259259 } ) . then ( ( ) => {
260260 return moveFromWelcomeToLogin ( matrixChat ) ;
261261 } ) . then ( ( ) => {
@@ -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- } ) . done ( done , done ) ;
275+ } ) . then ( done , done ) ;
276276 } ) ;
277277
278278 it ( 'should not register as a guest when using a #/login link' , function ( ) {
@@ -365,7 +365,7 @@ describe('loading:', function() {
365365 ReactTestUtils . findRenderedComponentWithType (
366366 matrixChat , sdk . getComponent ( 'structures.EmbeddedPage' ) ) ;
367367 expect ( windowLocation . hash ) . toEqual ( "#/home" ) ;
368- } ) . done ( done , done ) ;
368+ } ) . then ( done , done ) ;
369369 } ) ;
370370
371371 it ( 'shows a room view if we followed a room link' , function ( done ) {
@@ -385,7 +385,7 @@ describe('loading:', function() {
385385 } ) . then ( ( ) => {
386386 httpBackend . verifyNoOutstandingExpectation ( ) ;
387387 expect ( windowLocation . hash ) . toEqual ( "#/room/!room:id" ) ;
388- } ) . done ( done , done ) ;
388+ } ) . then ( done , done ) ;
389389 } ) ;
390390
391391 describe ( '/#/login link:' , function ( ) {
@@ -445,7 +445,7 @@ describe('loading:', function() {
445445 it ( 'shows a welcome page by default' , function ( done ) {
446446 loadApp ( ) ;
447447
448- Promise . delay ( 1 ) . then ( ( ) => {
448+ 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- } ) . done ( done , done ) ;
472+ } ) . then ( done , done ) ;
473473 } ) ;
474474
475475 it ( 'uses the default homeserver to register with' , function ( done ) {
476476 loadApp ( ) ;
477477
478- Promise . delay ( 1 ) . then ( ( ) => {
478+ 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- } ) . done ( done , done ) ;
506+ } ) . then ( done , done ) ;
507507 } ) ;
508508
509509 it ( 'shows a room view if we followed a room link' , function ( done ) {
510510 loadApp ( {
511511 uriFragment : "#/room/!room:id" ,
512512 } ) ;
513- Promise . delay ( 1 ) . then ( ( ) => {
513+ 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- } ) . done ( done , done ) ;
536+ } ) . then ( done , done ) ;
537537 } ) ;
538538
539539 describe ( 'Login as user' , function ( ) {
@@ -600,7 +600,7 @@ describe('loading:', function() {
600600
601601 ReactTestUtils.Simulate.click(returnToApp);
602602
603- return Promise.delay (1).then(() => {
603+ return sleep (1).then(() => {
604604 // we should be straight back into the home page
605605 ReactTestUtils.findRenderedComponentWithType(
606606 matrixChat, sdk.getComponent('structures.EmbeddedPage'));
@@ -616,7 +616,7 @@ describe('loading:', function() {
616616 queryString : "?loginToken=secretToken&homeserver=https%3A%2F%2Fhomeserver&identityServer=https%3A%2F%2Fidserver" ,
617617 } ) ;
618618
619- Promise . delay ( 1 ) . then ( ( ) => {
619+ 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- } ) . done ( done , done ) ;
648+ } ) . then ( done , done ) ;
649649 } ) ;
650650 } ) ;
651651
@@ -664,7 +664,7 @@ describe('loading:', function() {
664664
665665 // Give the component some time to finish processing the login flows before
666666 // continuing.
667- await Promise . delay ( 100 ) ;
667+ await sleep ( 100 ) ;
668668
669669 httpBackend . when ( 'POST' , '/login' ) . check ( function ( req ) {
670670 expect ( req . data . type ) . toEqual ( 'm.login.password' ) ;
@@ -680,7 +680,7 @@ describe('loading:', function() {
680680
681681 return httpBackend . flush ( ) . then ( ( ) => {
682682 // Wait for another trip around the event loop for the UI to update
683- return Promise . delay ( 1 ) ;
683+ return sleep ( 1 ) ;
684684 } ) . then ( ( ) => {
685685 // we expect a spinner
686686 ReactTestUtils . findRenderedComponentWithType (
@@ -738,7 +738,7 @@ function awaitRoomView(matrixChat, retryLimit, retryCount) {
738738 throw new Error ( "MatrixChat still not ready after " +
739739 retryCount + " tries" ) ;
740740 }
741- return Promise . delay ( 0 ) . then ( ( ) => {
741+ return sleep ( 0 ) . then ( ( ) => {
742742 return awaitRoomView ( matrixChat , retryLimit , retryCount + 1 ) ;
743743 } ) ;
744744 }
0 commit comments