web: Components: Added re-render tests at PasswordInput component.

This commit is contained in:
Ilya Oleshko 2019-09-12 13:58:55 +03:00
parent 6e44af367d
commit 88c61677ac

View File

@ -1,5 +1,5 @@
import React from 'react';
import { mount } from 'enzyme';
import { mount, shallow } from 'enzyme';
import PasswordInput from '.';
const basePasswordSettings = {
@ -96,4 +96,44 @@ describe('<PasswordInput />', () => {
expect(wrapper.prop('isDisabled')).toEqual(true);
});
it('not re-render test', () => {
const wrapper = shallow(<PasswordInput {...baseProps} />).instance();
const shouldUpdate = wrapper.shouldComponentUpdate(wrapper.props, wrapper.state);
expect(shouldUpdate).toBe(false);
});
it('re-render test', () => {
const wrapper = shallow(<PasswordInput {...baseProps} />).instance();
const shouldUpdate = wrapper.shouldComponentUpdate({
inputName: 'demoPasswordInput',
emailInputName: 'demoEmailInput',
inputValue: '',
clipActionResource: 'Copy e-mail and password',
clipEmailResource: 'E-mail: ',
clipPasswordResource: 'Password: ',
tooltipPasswordTitle: 'Password must contain:',
tooltipPasswordLength: 'from 6 to 30 characters',
tooltipPasswordDigits: 'digits',
tooltipPasswordCapital: 'capital letters',
tooltipPasswordSpecial: 'special characters (!@#$%^&*)',
generatorSpecial: '!@#$%^&*',
passwordSettings: {
minLength: 8,
upperCase: false,
digits: false,
specSymbols: false
},
isDisabled: false,
placeholder: 'password',
onChange: () => jest.fn(),
onValidateInput: () => jest.fn(),
onCopyToClipboard: () => jest.fn()
}, wrapper.state);
expect(shouldUpdate).toBe(true);
});
});