diff --git a/web/ASC.Web.Components/src/components/password-input/password-input.test.js b/web/ASC.Web.Components/src/components/password-input/password-input.test.js index 6b52a00897..85b54bcf6a 100644 --- a/web/ASC.Web.Components/src/components/password-input/password-input.test.js +++ b/web/ASC.Web.Components/src/components/password-input/password-input.test.js @@ -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('', () => { expect(wrapper.prop('isDisabled')).toEqual(true); }); + + it('not re-render test', () => { + const wrapper = shallow().instance(); + + const shouldUpdate = wrapper.shouldComponentUpdate(wrapper.props, wrapper.state); + + expect(shouldUpdate).toBe(false); + }); + + it('re-render test', () => { + const wrapper = shallow().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); + }); });