-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #233 from actiontech/feature/DMS-840
[test]:(Account) Supplementary testing coverage
- Loading branch information
Showing
5 changed files
with
79 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,11 +7,20 @@ import account from '../../../../testUtils/mockApi/account'; | |
describe('test base/page/Account/UserEmail', () => { | ||
const updateUserInfoSpy = jest.fn(); | ||
const messageSuccessSpy = jest.fn(); | ||
const messageErrorSpy = jest.fn(); | ||
|
||
const customRender = (email?: string) => { | ||
return renderWithTheme( | ||
<UserEmail | ||
messageApi={{ success: messageSuccessSpy } as any} | ||
messageApi={{ | ||
success: messageSuccessSpy, | ||
error: messageErrorSpy, | ||
info: jest.fn(), | ||
warning: jest.fn(), | ||
loading: jest.fn(), | ||
open: jest.fn(), | ||
destroy: jest.fn() | ||
}} | ||
updateUserInfo={updateUserInfoSpy} | ||
userBaseInfo={{ email }} | ||
/> | ||
|
@@ -34,7 +43,7 @@ describe('test base/page/Account/UserEmail', () => { | |
}); | ||
|
||
it('execute the onSubmit after triggering the enter event', async () => { | ||
const { container } = customRender(); | ||
const { container } = customRender('[email protected]'); | ||
|
||
fireEvent.mouseEnter( | ||
getBySelector('.ant-row,.ant-row-space-between.ant-row-middle', container) | ||
|
@@ -46,10 +55,36 @@ describe('test base/page/Account/UserEmail', () => { | |
|
||
fireEvent.change(inputEle, { | ||
target: { | ||
value: '[email protected]' | ||
value: 'submit.com' | ||
} | ||
}); | ||
fireEvent.keyDown(inputEle, { | ||
key: 'Enter', | ||
code: 'Enter', | ||
keyCode: 13 | ||
}); | ||
expect(messageErrorSpy).toBeCalledTimes(1); | ||
expect(messageErrorSpy).toBeCalledWith('请输入正确格式的邮箱地址'); | ||
|
||
fireEvent.change(inputEle, { | ||
target: { | ||
value: '[email protected]' | ||
} | ||
}); | ||
fireEvent.keyDown(inputEle, { | ||
key: 'Enter', | ||
code: 'Enter', | ||
keyCode: 13 | ||
}); | ||
expect(messageErrorSpy).toBeCalledTimes(2); | ||
expect(messageErrorSpy).toBeCalledWith('新邮箱地址不能与旧地址一致'); | ||
expect(updateCurrentUserSpy).toBeCalledTimes(0); | ||
|
||
fireEvent.change(inputEle, { | ||
target: { | ||
value: '[email protected]' | ||
} | ||
}); | ||
fireEvent.keyDown(inputEle, { | ||
key: 'Enter', | ||
code: 'Enter', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ exports[`test base/page/Account/UserEmail execute the onSubmit after triggering | |
class="ant-space-item" | ||
style="margin-right: 8px;" | ||
> | ||
- | ||
[email protected] | ||
</div> | ||
<div | ||
class="ant-space-item" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters