summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--web-ui/src/backup_account/page.js6
-rw-r--r--web-ui/src/backup_account/page.spec.js4
4 files changed, 14 insertions, 13 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');
});
});
});
diff --git a/web-ui/src/backup_account/page.js b/web-ui/src/backup_account/page.js
index 221c6978..49e4b316 100644
--- a/web-ui/src/backup_account/page.js
+++ b/web-ui/src/backup_account/page.js
@@ -34,10 +34,8 @@ export class Page extends React.Component {
this.state = { status: '' };
}
- saveBackupEmail = () => {
- this.setState({
- status: 'success'
- });
+ saveBackupEmail = (status) => {
+ this.setState({ status });
}
mainContent = () => {
diff --git a/web-ui/src/backup_account/page.spec.js b/web-ui/src/backup_account/page.spec.js
index 23c117a0..bd7bb884 100644
--- a/web-ui/src/backup_account/page.spec.js
+++ b/web-ui/src/backup_account/page.spec.js
@@ -29,7 +29,7 @@ describe('BackupAccount', () => {
});
it('changes state', () => {
- pageInstance.saveBackupEmail();
+ pageInstance.saveBackupEmail('success');
expect(pageInstance.state.status).toEqual('success');
});
@@ -38,7 +38,7 @@ describe('BackupAccount', () => {
});
it('renders confirmation component', () => {
- pageInstance.saveBackupEmail();
+ pageInstance.saveBackupEmail('success');
expect(page.find(Confirmation).length).toEqual(1);
});
});