diff options
author | Sriram Viswanathan <sriramv@thoughtworks.com> | 2017-03-28 14:48:45 -0300 |
---|---|---|
committer | Sriram Viswanathan <sriramv@thoughtworks.com> | 2017-03-28 14:53:12 -0300 |
commit | 6f9de40da695e5701104788e3216996b7950087d (patch) | |
tree | 9edd99f07d7b4d5bb653284f770425acfbae374c /web-ui/src/backup_account/backup_email/backup_email.spec.js | |
parent | a9462a5d761aab4d4bcd89412fb265155c981972 (diff) |
[#931] Shows error feedback using Snackbar notification when there's a submit failure on backup account page
Diffstat (limited to 'web-ui/src/backup_account/backup_email/backup_email.spec.js')
-rw-r--r-- | web-ui/src/backup_account/backup_email/backup_email.spec.js | 27 |
1 files changed, 25 insertions, 2 deletions
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 48199738..ce357bf7 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 @@ -84,7 +84,7 @@ describe('BackupEmail', () => { }); }); - describe('Submit', () => { + describe('Submit on success', () => { let preventDefaultSpy; beforeEach((done) => { @@ -118,8 +118,31 @@ describe('BackupEmail', () => { expect(preventDefaultSpy).toHaveBeenCalled(); }); - it('calls onSubmit from props when success', () => { + it('calls onSubmit from props with success', () => { expect(mockOnSubmit).toHaveBeenCalledWith('success'); }); }); + + describe('Submit on error', () => { + let preventDefaultSpy; + + 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', 500); + backupEmail.find('form').simulate('submit', { preventDefault: preventDefaultSpy }); + }); + + it('calls onSubmit from props with error', () => { + expect(mockOnSubmit).toHaveBeenCalledWith('error'); + }); + }); + + afterEach(() => { + fetchMock.restore(); + }); }); |