UNPKG

tin-react-components

Version:
33 lines (32 loc) 1.2 kB
import React from 'react' import { mount } from 'enzyme' import { expect } from 'chai' import sinon from 'sinon' import Input from '../index' /** * @author: undefined */ describe('<Input />', () => { const onChange = sinon.spy() const inputLabels = ['Label 1', 'Label 2', 'Label 3'] const inputValues = ['Value 1', 'Value 2', 'Value 3'] it('should show a label', () => { const wrapper = mount(<Input onChange={onChange} label='Label' />) expect(wrapper.find('label')).to.have.length(1) }) inputLabels.forEach((label, i) => { it(`should show an element with ${label} as the label, given the property 'label' === ${label}`, () => { const wrapper = mount(<Input onChange={onChange} label={label} />) expect(wrapper.find('label').text()).to.equal(label) expect(wrapper.props().label).to.equal(label) }) }) inputValues.forEach((value, i) => { it(`should show an element with ${value} as the text, given the property 'value' === ${value}`, () => { const wrapper = mount(<Input onChange={onChange} value={value} />) const val = wrapper.find('input').props().value console.log(val) expect(val).to.equal(value) }) }) })