1
1
import React from 'react' ;
2
2
3
- import {
4
- renderApollo ,
5
- cleanup ,
6
- fireEvent ,
7
- waitForElement ,
8
- } from '../../test-utils' ;
9
- import Login , { LOGIN_USER } from '../login' ;
3
+ import { renderApollo , cleanup , fireEvent , waitFor } from '../../test-utils' ;
4
+ import Login , { LOGIN_USER } from '../login' ;
10
5
import { cache , isLoggedInVar } from '../../cache' ;
11
6
12
7
describe ( 'Login Page' , ( ) => {
@@ -22,7 +17,7 @@ describe('Login Page', () => {
22
17
23
18
const mocks = [
24
19
{
25
- request :{ query :LOGIN_USER , variables :{ email :'a@a.a' } } ,
20
+ request :{ query :LOGIN_USER , variables :{ email :'a@a.a' } } ,
26
21
result :{
27
22
data :{
28
23
login :{
@@ -34,19 +29,19 @@ describe('Login Page', () => {
34
29
} ,
35
30
] ;
36
31
37
- const { getByText, getByTestId} = await renderApollo ( < Login /> , {
32
+ const { getByText, getByTestId} = await renderApollo ( < Login /> , {
38
33
mocks,
39
34
cache,
40
35
} ) ;
41
36
42
37
fireEvent . change ( getByTestId ( 'login-input' ) , {
43
- target :{ value :'a@a.a' } ,
38
+ target :{ value :'a@a.a' } ,
44
39
} ) ;
45
40
46
41
fireEvent . click ( getByText ( / l o g i n / i) ) ;
47
42
48
43
// login is done if loader is gone
49
- await waitForElement ( ( ) => getByText ( / l o g i n / i) ) ;
44
+ await waitFor ( ( ) => getByText ( / l o g i n / i) ) ;
50
45
51
46
expect ( isLoggedInVar ( ) ) . toBeTruthy ( ) ;
52
47
} ) ;