Added different Select Fields (#1583)

* Added different Select Fields
 - Switched FormGroup to react-select
 - Added multi and freeform to select, now it can take customized user
   input and insert it as options

* Fixed tests

* Small nit based on comments
This commit is contained in:
vera-liu
2016-11-13 14:11:52 -08:00
committed by GitHub
parent 4155a9d7f9
commit 2133056c04
4 changed files with 62 additions and 32 deletions

View File

@@ -1,6 +1,6 @@
/* eslint-disable no-unused-expressions */
import React from 'react';
import { FormControl } from 'react-bootstrap';
import Select, { Creatable } from 'react-select';
import sinon from 'sinon';
import { expect } from 'chai';
import { describe, it, beforeEach } from 'mocha';
@@ -21,13 +21,18 @@ describe('SelectField', () => {
wrapper = shallow(<SelectField {...defaultProps} />);
});
it('renders a FormControl', () => {
expect(wrapper.find(FormControl)).to.have.lengthOf(1);
it('renders a Select', () => {
expect(wrapper.find(Select)).to.have.lengthOf(1);
});
it('calls onChange when toggled', () => {
const select = wrapper.find(FormControl);
select.simulate('change', { target: { value: 50 } });
const select = wrapper.find(Select);
select.simulate('change', { value: 50 });
expect(defaultProps.onChange.calledWith('row_limit', 50)).to.be.true;
});
it('renders a Creatable for freeform', () => {
wrapper = shallow(<SelectField {...defaultProps} freeForm />);
expect(wrapper.find(Creatable)).to.have.lengthOf(1);
});
});