summaryrefslogtreecommitdiff
path: root/web-ui/src/backup_account/backup_email
diff options
context:
space:
mode:
Diffstat (limited to 'web-ui/src/backup_account/backup_email')
-rw-r--r--web-ui/src/backup_account/backup_email/backup_email.js4
-rw-r--r--web-ui/src/backup_account/backup_email/backup_email.spec.js13
2 files changed, 10 insertions, 7 deletions
diff --git a/web-ui/src/backup_account/backup_email/backup_email.js b/web-ui/src/backup_account/backup_email/backup_email.js
index 32d17935..09863950 100644
--- a/web-ui/src/backup_account/backup_email/backup_email.js
+++ b/web-ui/src/backup_account/backup_email/backup_email.js
@@ -54,9 +54,7 @@ export class BackupEmail extends React.Component {
body: JSON.stringify({
csrftoken: [browser.getCookie('XSRF-TOKEN')]
})
- });
-
- this.props.onSubmit();
+ }).then(() => this.props.onSubmit('success'));
}
render() {
diff --git a/web-ui/src/backup_account/backup_email/backup_email.spec.js b/web-ui/src/backup_account/backup_email/backup_email.spec.js
index 66dc8df6..48199738 100644
--- a/web-ui/src/backup_account/backup_email/backup_email.spec.js
+++ b/web-ui/src/backup_account/backup_email/backup_email.spec.js
@@ -8,10 +8,12 @@ import browser from 'helpers/browser';
describe('BackupEmail', () => {
let backupEmail;
let mockOnSubmit;
+ let mockTranslations;
beforeEach(() => {
mockOnSubmit = expect.createSpy();
- const mockTranslations = key => key;
+
+ mockTranslations = key => key;
backupEmail = shallow(<BackupEmail t={mockTranslations} onSubmit={mockOnSubmit} />);
});
@@ -85,10 +87,13 @@ describe('BackupEmail', () => {
describe('Submit', () => {
let preventDefaultSpy;
- beforeEach(() => {
+ beforeEach((done) => {
+ mockOnSubmit = expect.createSpy().andCall(() => done());
preventDefaultSpy = expect.createSpy();
expect.spyOn(browser, 'getCookie').andReturn('abc123');
+ backupEmail = shallow(<BackupEmail t={mockTranslations} onSubmit={mockOnSubmit} />);
+
fetchMock.post('/backup-account', 204);
backupEmail.find('form').simulate('submit', { preventDefault: preventDefaultSpy });
});
@@ -113,8 +118,8 @@ describe('BackupEmail', () => {
expect(preventDefaultSpy).toHaveBeenCalled();
});
- it('calls onSubmit from props', () => {
- expect(mockOnSubmit).toHaveBeenCalled();
+ it('calls onSubmit from props when success', () => {
+ expect(mockOnSubmit).toHaveBeenCalledWith('success');
});
});
});