-
Notifications
You must be signed in to change notification settings - Fork 71
[#971] Add backup account confirmation page #1011
Conversation
@@ -39,16 +40,23 @@ export class BackupEmail extends React.Component { | |||
}); | |||
} | |||
|
|||
submitHandler = (event) => { | |||
event.preventDefault(); | |||
if (typeof this.props.onSubmit === 'function') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this if necessary if we define that onSubmit is required (as you said it was required in the propTypes? I think we should avoid it.
@@ -23,6 +24,15 @@ describe('BackupEmail', () => { | |||
expect(page.find('SubmitButton').props().buttonText).toEqual('backup-account.backup-email.button'); | |||
}); | |||
|
|||
it('form submit should call parameter custom submit', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Messages for tests should always start with a verb, since the syntax is: "BackupEmail calls...". Mocha follows the rule of describe(<ComponentName>)
, context(<Situation>)
, it(<action>)
.
const event = { preventDefault() {} }; | ||
page = shallow(<BackupEmail t={mockTranslations} onSubmit={mockOnSubmit} />); | ||
|
||
page.instance().submitHandler(event); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, we could simulate a form submit to test that onSubmit was called.
backupEmail.find('form').simulate('submit', { preventDefault: () => {} });
expect(mockOnSubmit).toHaveBeenCalled();
expect(page.find('a').text()).toEqual('backup-account.confirmation.retry-button'); | ||
}); | ||
|
||
it('retry button redirects to backup account', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"retry" => "retries"
pageInstance = page.instance(); | ||
}); | ||
|
||
it('verify initial state', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"verify" => "verifies"
it('changes state', () => { | ||
pageInstance.saveBackupEmail(); | ||
expect(pageInstance.state.status).toEqual('success'); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no test for checking if we are rendering Confirmation or BackupEmail component. 😢
@thaissiqueira and @anikarni As we talked, we fixed the issues in the confirmation.spec.js and page.spec.js |
1103ec9
to
a36902d
Compare
We still have to do the css for the confirmation page.