Replace usages of Promise.delay(...) with own utils

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
pull/21833/head
Michael Telatynski 2019-11-14 14:25:54 +00:00
parent 41f4f3ef82
commit b3760cdd6e
2 changed files with 4 additions and 2 deletions

View File

@ -26,6 +26,7 @@ import sdk from 'matrix-react-sdk';
import MatrixClientPeg from '../../../../src/MatrixClientPeg'; import MatrixClientPeg from '../../../../src/MatrixClientPeg';
import * as test_utils from '../../../test-utils'; import * as test_utils from '../../../test-utils';
import {sleep} from "../../../../src/utils/promise";
const InteractiveAuthDialog = sdk.getComponent( const InteractiveAuthDialog = sdk.getComponent(
'views.dialogs.InteractiveAuthDialog', 'views.dialogs.InteractiveAuthDialog',
@ -107,7 +108,7 @@ describe('InteractiveAuthDialog', function() {
}, },
})).toBe(true); })).toBe(true);
// let the request complete // let the request complete
return Promise.delay(1); return sleep(1);
}).then(() => { }).then(() => {
expect(onFinished.callCount).toEqual(1); expect(onFinished.callCount).toEqual(1);
expect(onFinished.calledWithExactly(true, {a: 1})).toBe(true); expect(onFinished.calledWithExactly(true, {a: 1})).toBe(true);

View File

@ -8,6 +8,7 @@ import * as testUtils from '../../../test-utils';
import sdk from 'matrix-react-sdk'; import sdk from 'matrix-react-sdk';
const MessageComposerInput = sdk.getComponent('views.rooms.MessageComposerInput'); const MessageComposerInput = sdk.getComponent('views.rooms.MessageComposerInput');
import MatrixClientPeg from '../../../../src/MatrixClientPeg'; import MatrixClientPeg from '../../../../src/MatrixClientPeg';
import {sleep} from "../../../../src/utils/promise";
function addTextToDraft(text) { function addTextToDraft(text) {
const components = document.getElementsByClassName('public-DraftEditor-content'); const components = document.getElementsByClassName('public-DraftEditor-content');
@ -49,7 +50,7 @@ xdescribe('MessageComposerInput', () => {
// warnings // warnings
// (please can we make the components not setState() after // (please can we make the components not setState() after
// they are unmounted?) // they are unmounted?)
Promise.delay(10).done(() => { sleep(10).done(() => {
if (parentDiv) { if (parentDiv) {
ReactDOM.unmountComponentAtNode(parentDiv); ReactDOM.unmountComponentAtNode(parentDiv);
parentDiv.remove(); parentDiv.remove();