Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@doodle/components / src / components / controls / Input / __tests__ / InputFieldForPassword.spec.js
Size: Mime:
import React from 'react';
import { mount, shallow } from 'enzyme';

import InputFieldForPassword from '../InputFieldForPassword';

describe('InputFieldForPassword', () => {
  it('changes the input type to "text" when the button is clicked', () => {
    // given
    const component = mount(<InputFieldForPassword semantic="My test field" />);
    // when
    component.find('button').simulate('click');
    // then
    expect(component.find('input').prop('type')).toBe('text');
  });

  it('changes the input type back to "password" when the button is clicked again', () => {
    // given
    const component = mount(<InputFieldForPassword semantic="My test field" />);
    component.setState({
      showPassword: true,
    });
    // when
    component.find('button').simulate('click');
    // then
    expect(component.find('input').prop('type')).toBe('password');
  });

  it('matches the snapshot: password hidden', () => {
    const component = shallow(<InputFieldForPassword semantic="My test field" />);
    expect(component).toMatchSnapshot();
  });

  it('matches the snapshot: password visible', () => {
    const component = shallow(<InputFieldForPassword semantic="My test field" />);
    component.setState({
      showPassword: true,
    });
    expect(component).toMatchSnapshot();
  });
});