2017-01-20 17:52:57 +00:00
|
|
|
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');
|
2019-01-14 21:45:28 +00:00
|
|
|
let secretInput = component.find('.add-host-modal__secret-input').find('input');
|
2017-01-20 17:52:57 +00:00
|
|
|
|
|
|
|
|
expect(component.state().revealSecret).toEqual(false);
|
|
|
|
|
expect(secretInput.prop('type')).toEqual('password');
|
|
|
|
|
expect(revealSecretLink.text()).toEqual('Reveal Secret');
|
|
|
|
|
|
|
|
|
|
revealSecretLink.simulate('click');
|
|
|
|
|
|
2019-01-14 21:45:28 +00:00
|
|
|
secretInput = component.find('.add-host-modal__secret-input').find('input');
|
2017-01-20 17:52:57 +00:00
|
|
|
expect(component.state().revealSecret).toEqual(true);
|
|
|
|
|
expect(secretInput.prop('type')).toEqual('text');
|
|
|
|
|
expect(revealSecretLink.text()).toEqual('Hide Secret');
|
|
|
|
|
|
|
|
|
|
revealSecretLink.simulate('click');
|
|
|
|
|
|
2019-01-14 21:45:28 +00:00
|
|
|
secretInput = component.find('.add-host-modal__secret-input').find('input');
|
2017-01-20 17:52:57 +00:00
|
|
|
expect(component.state().revealSecret).toEqual(false);
|
|
|
|
|
expect(secretInput.prop('type')).toEqual('password');
|
|
|
|
|
expect(revealSecretLink.text()).toEqual('Reveal Secret');
|
|
|
|
|
});
|
|
|
|
|
});
|