mirror of
https://github.com/strapi/strapi.git
synced 2025-08-12 10:48:12 +00:00
headersInput tests
Signed-off-by: Virginie Ky <virginie.ky@gmail.com>
This commit is contained in:
parent
dfd6c51ca8
commit
00b664ea61
@ -132,19 +132,16 @@ const HeadersInput = ({ errors, name, onClick, onChange, onRemove, value }) => {
|
||||
|
||||
HeadersInput.defaultProps = {
|
||||
errors: {},
|
||||
handleClick: () => {},
|
||||
onClick: () => {},
|
||||
onRemove: () => {},
|
||||
};
|
||||
|
||||
HeadersInput.propTypes = {
|
||||
errors: PropTypes.object,
|
||||
handleClick: PropTypes.func,
|
||||
name: PropTypes.string.isRequired,
|
||||
onChange: PropTypes.func.isRequired,
|
||||
onClick: PropTypes.func.isRequired,
|
||||
onRemove: PropTypes.func,
|
||||
value: PropTypes.array,
|
||||
value: PropTypes.array.isRequired,
|
||||
};
|
||||
|
||||
export default HeadersInput;
|
||||
|
@ -1,10 +1,11 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import CreatableSelect from 'react-select/creatable';
|
||||
|
||||
import { InputText } from '@buffetjs/core';
|
||||
import { CircleButton } from 'strapi-helper-plugin';
|
||||
import HeadersInput from '../index';
|
||||
|
||||
|
||||
describe('Admin | components | HeadersInput', () => {
|
||||
const props = {
|
||||
name: 'headers',
|
||||
@ -22,6 +23,12 @@ describe('Admin | components | HeadersInput', () => {
|
||||
it('It should render properly', () => {
|
||||
shallow(<HeadersInput {...props} />);
|
||||
});
|
||||
|
||||
it('It should render as many key/value rows as value', () => {
|
||||
const renderedComponent = shallow(<HeadersInput {...props} />);
|
||||
|
||||
expect(renderedComponent.find(CreatableSelect)).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Actions', () => {
|
||||
@ -31,7 +38,7 @@ describe('Admin | components | HeadersInput', () => {
|
||||
const removeButton = renderedComponent.find(CircleButton).at(0);
|
||||
removeButton.simulate('click');
|
||||
|
||||
expect(props.onRemove).toHaveBeenCalled();
|
||||
expect(props.onRemove).toHaveBeenCalledWith(0);
|
||||
});
|
||||
});
|
||||
|
||||
@ -43,4 +50,17 @@ describe('Admin | components | HeadersInput', () => {
|
||||
|
||||
expect(props.onClick).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('It should call the onChange props on input text change', () => {
|
||||
const renderedComponent = shallow(<HeadersInput {...props} />);
|
||||
|
||||
const input = renderedComponent.find(InputText).at(0);
|
||||
input.simulate('change');
|
||||
|
||||
expect(props.onChange).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should have default onRemove', () => {
|
||||
expect(HeadersInput.defaultProps.onRemove).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
@ -6,7 +6,7 @@ const List = styled.ul`
|
||||
margin-bottom: 0;
|
||||
padding-left: 0;
|
||||
max-height: 251px;
|
||||
overflow-y: scroll;
|
||||
overflow-y: auto;
|
||||
li {
|
||||
position: relative;
|
||||
margin-bottom: 2px;
|
||||
|
Loading…
x
Reference in New Issue
Block a user