[exploreV2] mapStateToProps for fields (#1882)

* Controls support for mapStateToProps

* Binding methods in the constructor

* Adressing comments

* Fixing tests
This commit is contained in:
Maxime Beauchemin
2017-01-06 12:38:44 -08:00
committed by GitHub
parent 9a62d94630
commit 222671675c
11 changed files with 193 additions and 217 deletions

View File

@@ -1,31 +1,18 @@
import React from 'react';
import { expect } from 'chai';
import { describe, it, beforeEach } from 'mocha';
import { describe, it } from 'mocha';
import { shallow } from 'enzyme';
import { fields } from '../../../../javascripts/explorev2/stores/fields';
import { defaultFormData } from '../../../../javascripts/explorev2/stores/store';
import FieldSetRow from '../../../../javascripts/explorev2/components/FieldSetRow';
import FieldSet from '../../../../javascripts/explorev2/components/FieldSet';
const defaultProps = {
fields,
fieldSets: ['columns', 'metrics'],
form_data: defaultFormData(),
};
describe('FieldSetRow', () => {
let wrapper;
beforeEach(() => {
wrapper = shallow(<FieldSetRow {...defaultProps} />);
});
it('renders a single row element', () => {
it('renders a single row with one element', () => {
const wrapper = shallow(<FieldSetRow fields={[<a />]} />);
expect(wrapper.find('.row')).to.have.lengthOf(1);
expect(wrapper.find('.row').find('a')).to.have.lengthOf(1);
});
it('renders a FieldSet for each item in fieldSets array', () => {
const length = defaultProps.fieldSets.length;
expect(wrapper.find(FieldSet)).to.have.lengthOf(length);
it('renders a single row with two elements', () => {
const wrapper = shallow(<FieldSetRow fields={[<a />, <a />]} />);
expect(wrapper.find('.row')).to.have.lengthOf(1);
expect(wrapper.find('.row').find('a')).to.have.lengthOf(2);
});
});