@@ -14,12 +14,18 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17+ import sdk from '../../../skinned-sdk' ;
18+
1719import React from 'react' ;
1820import ReactDOM from 'react-dom' ;
1921import ReactTestUtils from 'react-dom/test-utils' ;
20- import sdk from '../../../skinned-sdk' ;
22+ import { createClient } from 'matrix-js-sdk/src/matrix' ;
23+
2124import SdkConfig from '../../../../src/SdkConfig' ;
22- import { mkServerConfig } from "../../../test-utils" ;
25+ import { createTestClient , mkServerConfig } from "../../../test-utils" ;
26+
27+ jest . mock ( 'matrix-js-sdk/src/matrix' ) ;
28+ jest . useFakeTimers ( ) ;
2329
2430const Registration = sdk . getComponent (
2531 'structures.auth.Registration' ,
@@ -31,6 +37,7 @@ describe('Registration', function() {
3137 beforeEach ( function ( ) {
3238 parentDiv = document . createElement ( 'div' ) ;
3339 document . body . appendChild ( parentDiv ) ;
40+ createClient . mockImplementation ( ( ) => createTestClient ( ) ) ;
3441 } ) ;
3542
3643 afterEach ( function ( ) {
@@ -48,13 +55,13 @@ describe('Registration', function() {
4855 /> , parentDiv ) ;
4956 }
5057
51- it ( 'should show server picker' , function ( ) {
58+ it ( 'should show server picker' , async function ( ) {
5259 const root = render ( ) ;
5360 const selector = ReactTestUtils . findRenderedDOMComponentWithClass ( root , "mx_ServerPicker" ) ;
5461 expect ( selector ) . toBeTruthy ( ) ;
5562 } ) ;
5663
57- it ( 'should show form when custom URLs disabled' , function ( ) {
64+ it ( 'should show form when custom URLs disabled' , async function ( ) {
5865 jest . spyOn ( SdkConfig , "get" ) . mockReturnValue ( {
5966 disable_custom_urls : true ,
6067 } ) ;
@@ -77,7 +84,7 @@ describe('Registration', function() {
7784 expect ( form ) . toBeTruthy ( ) ;
7885 } ) ;
7986
80- it ( "should show SSO options if those are available" , ( ) => {
87+ it ( "should show SSO options if those are available" , async ( ) => {
8188 jest . spyOn ( SdkConfig , "get" ) . mockReturnValue ( {
8289 disable_custom_urls : true ,
8390 } ) ;
0 commit comments