fleet/frontend/components/hosts/AddHostModal/AddHostModal.tests.jsx
Zachary Wasserman 6767369d48
Upgrade React to version 16 (#1983)
- Update all associated dependencies
- Very minimal changes to components
- Extensive refactoring for broken tests

Closes #1978
2019-01-14 13:45:28 -08:00

32 lines
1.3 KiB
JavaScript

import React from 'react';
import expect from 'expect';
import { mount } from 'enzyme';
import { noop } from 'lodash';
import AddHostModal from './AddHostModal';
describe('AddHostModal - component', () => {
it('clicking Reveal Secret should change input type', () => {
const component = mount(<AddHostModal dispatch={noop} onReturnToApp={noop} />);
const revealSecretLink = component.find('.add-host-modal__reveal-secret');
let secretInput = component.find('.add-host-modal__secret-input').find('input');
expect(component.state().revealSecret).toEqual(false);
expect(secretInput.prop('type')).toEqual('password');
expect(revealSecretLink.text()).toEqual('Reveal Secret');
revealSecretLink.simulate('click');
secretInput = component.find('.add-host-modal__secret-input').find('input');
expect(component.state().revealSecret).toEqual(true);
expect(secretInput.prop('type')).toEqual('text');
expect(revealSecretLink.text()).toEqual('Hide Secret');
revealSecretLink.simulate('click');
secretInput = component.find('.add-host-modal__secret-input').find('input');
expect(component.state().revealSecret).toEqual(false);
expect(secretInput.prop('type')).toEqual('password');
expect(revealSecretLink.text()).toEqual('Reveal Secret');
});
});