This repository was archived by the owner on Apr 11, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +22
-48
lines changed Expand file tree Collapse file tree 6 files changed +22
-48
lines changed Original file line number Diff line number Diff line change @@ -2,41 +2,25 @@ import React from 'react';
2
2
import { render } from '@testing-library/react' ;
3
3
4
4
import { Footer } from './index' ;
5
- import { IntlProvider } from '../Intl ' ;
5
+ import '../../locales ' ;
6
6
7
7
describe ( 'Footer 组件' , ( ) => {
8
8
it ( '登录页脚' , ( ) => {
9
- const { container } = render (
10
- < IntlProvider >
11
- < Footer type = { 'login' } />
12
- </ IntlProvider > ,
13
- ) ;
9
+ const { container } = render ( < Footer type = { 'login' } /> ) ;
14
10
expect ( container ) . toMatchSnapshot ( ) ;
15
11
} ) ;
16
12
it ( '微信登陆页面' , ( ) => {
17
- const { container } = render (
18
- < IntlProvider >
19
- < Footer type = { 'register' } onWechatLoginClick = { ( ) => { } } />
20
- </ IntlProvider > ,
21
- ) ;
13
+ const { container } = render ( < Footer type = { 'register' } onWechatLoginClick = { ( ) => { } } /> ) ;
22
14
expect ( container ) . toMatchSnapshot ( ) ;
23
15
} ) ;
24
16
it ( '忘记密码' , ( ) => {
25
- const { container } = render (
26
- < IntlProvider >
27
- < Footer type = { 'forgot' } />
28
- </ IntlProvider > ,
29
- ) ;
17
+ const { container } = render ( < Footer type = { 'forgot' } /> ) ;
30
18
expect ( container ) . toMatchSnapshot ( ) ;
31
19
} ) ;
32
20
it ( '空' , ( ) => {
33
21
const { container } = render (
34
- < IntlProvider >
35
- < Footer
36
- // @ts -ignore
37
- type = { '' }
38
- />
39
- </ IntlProvider > ,
22
+ // @ts -ignore
23
+ < Footer type = { '' } /> ,
40
24
) ;
41
25
expect ( container ) . toMatchSnapshot ( ) ;
42
26
} ) ;
Original file line number Diff line number Diff line change @@ -2,15 +2,11 @@ import React from 'react';
2
2
import { render } from '@testing-library/react' ;
3
3
4
4
import { Header } from './index' ;
5
- import { IntlProvider } from '../Intl ' ;
5
+ import '../../locales ' ;
6
6
7
7
describe ( 'Header 组件' , ( ) => {
8
8
it ( '登录头部' , ( ) => {
9
- const { container } = render (
10
- < IntlProvider >
11
- < Header type = { 'login' } />
12
- </ IntlProvider > ,
13
- ) ;
9
+ const { container } = render ( < Header type = { 'login' } /> ) ;
14
10
expect ( container ) . toMatchSnapshot ( ) ;
15
11
} ) ;
16
12
} ) ;
Original file line number Diff line number Diff line change @@ -3,36 +3,24 @@ import { render, fireEvent } from '@testing-library/react';
3
3
import { act } from '@testing-library/react-hooks' ;
4
4
5
5
import WechatLogin from './index' ;
6
- import { IntlProvider } from '../Intl ' ;
6
+ import '../../locales ' ;
7
7
8
8
describe ( 'WechatLogin 组件' , ( ) => {
9
9
it ( '默认状态' , ( ) => {
10
- const { container } = render (
11
- < IntlProvider >
12
- < WechatLogin />
13
- </ IntlProvider > ,
14
- ) ;
10
+ const { container } = render ( < WechatLogin /> ) ;
15
11
expect ( container ) . toMatchSnapshot ( ) ;
16
12
} ) ;
17
13
18
14
it ( '点击微信登录按钮' , async ( ) => {
19
15
const fn = jest . fn ( ) ;
20
- const { findByTestId } = render (
21
- < IntlProvider >
22
- < WechatLogin login = { fn } />
23
- </ IntlProvider > ,
24
- ) ;
16
+ const { findByTestId } = render ( < WechatLogin login = { fn } /> ) ;
25
17
const btn = await findByTestId ( 'wechat-btn' ) ;
26
18
fireEvent . click ( btn ) ;
27
19
28
20
expect ( fn ) . toBeCalledTimes ( 1 ) ;
29
21
} ) ;
30
22
it ( '没有实现方法时报错' , async ( ) => {
31
- const { findByTestId } = render (
32
- < IntlProvider >
33
- < WechatLogin />
34
- </ IntlProvider > ,
35
- ) ;
23
+ const { findByTestId } = render ( < WechatLogin /> ) ;
36
24
37
25
const btn = await findByTestId ( 'wechat-btn' ) ;
38
26
Original file line number Diff line number Diff line change 1
1
export default {
2
2
'login.accountLogin.tab' : 'Account Login' ,
3
- 'login.accountLogin.errorMessage' :
4
- 'Incorrect username/password(admin/ant.design)' ,
5
- 'login.username.placeholder' : 'Username: admin or user' ,
3
+ 'login.accountLogin.errorMessage' : 'Incorrect username/password' ,
4
+ 'login.username.placeholder' : 'Username' ,
6
5
'login.username.required' : 'Please input your username!' ,
7
- 'login.password.placeholder' : 'Password: ant.design ' ,
6
+ 'login.password.placeholder' : 'Password' ,
8
7
'login.password.required' : 'Please input your password!' ,
9
8
'login.phoneLogin.tab' : 'Phone Login' ,
10
9
'login.phoneLogin.errorMessage' : 'Verification Code Error' ,
Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ import React from 'react';
4
4
import { render , fireEvent , act } from '@testing-library/react' ;
5
5
6
6
import Login from './index' ;
7
+ import '../locales' ;
8
+ import i18n from '../locales' ;
9
+
10
+ i18n . changeLanguage ( 'zh-CN' ) ;
7
11
8
12
describe ( 'Login 组件' , ( ) => {
9
13
it ( '默认状态' , ( ) => {
Original file line number Diff line number Diff line change @@ -2,6 +2,9 @@ import React from 'react';
2
2
import { render , fireEvent , act } from '@testing-library/react' ;
3
3
4
4
import UserPanel from '@arvinxu/user-panel' ;
5
+ import i18n from '../src/locales' ;
6
+
7
+ i18n . changeLanguage ( 'zh-CN' ) ;
5
8
6
9
describe ( 'UserPanel' , ( ) => {
7
10
it ( '登录面板' , async ( ) => {
You can’t perform that action at this time.
0 commit comments