blob: 386c3a1914b9a762afcf083acfbb34327e154fa7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
import { shallow } from 'enzyme';
import expect from 'expect';
import React from 'react';
import { UserRecoveryCodeForm } from './user_recovery_code_form';
describe('UserRecoveryCodeForm', () => {
let userRecoveryCodeForm;
let mockNext;
let mockPrevious;
let mockSaveCode;
beforeEach(() => {
const mockTranslations = key => key;
mockNext = expect.createSpy();
mockPrevious = expect.createSpy();
mockSaveCode = expect.createSpy();
userRecoveryCodeForm = shallow(
<UserRecoveryCodeForm
t={mockTranslations} next={mockNext}
previous={mockPrevious} saveCode={mockSaveCode}
/>
);
});
it('renders title for user recovery code', () => {
expect(userRecoveryCodeForm.find('h1').text()).toEqual('account-recovery.user-form.title');
});
it('renders description', () => {
expect(userRecoveryCodeForm.find('p').text()).toEqual('account-recovery.user-form.description');
});
it('renders input for user code', () => {
expect(userRecoveryCodeForm.find('InputField').props().label).toEqual('account-recovery.user-form.input-label');
});
it('renders submit button', () => {
expect(userRecoveryCodeForm.find('SubmitButton').props().buttonText).toEqual('account-recovery.button-next');
});
it('submits form to next step', () => {
userRecoveryCodeForm.find('form').simulate('submit');
expect(mockNext).toHaveBeenCalled();
});
it('returns to previous step on link click', () => {
userRecoveryCodeForm.find('BackLink').simulate('click');
expect(mockPrevious).toHaveBeenCalled();
});
it('saves code on input change', () => {
userRecoveryCodeForm.find('InputField').simulate('change', '123');
expect(mockSaveCode).toHaveBeenCalledWith('123');
});
});
|