[explore] viz type selector as modal (#2787)

* [explore] viz type selector as modal

* Addressing comments

* Adressing comments
This commit is contained in:
Maxime Beauchemin
2017-05-30 11:05:18 -07:00
committed by GitHub
parent 3a4cd3ae24
commit 66403f1876
8 changed files with 184 additions and 12 deletions

View File

@@ -0,0 +1,37 @@
import React from 'react';
import sinon from 'sinon';
import { expect } from 'chai';
import { describe, it, beforeEach } from 'mocha';
import { shallow } from 'enzyme';
import { Modal } from 'react-bootstrap';
import VizTypeControl from '../../../../javascripts/explore/components/controls/VizTypeControl';
const defaultProps = {
name: 'viz_type',
label: 'Visualization Type',
value: 'table',
onChange: sinon.spy(),
};
describe('VizTypeControl', () => {
let wrapper;
beforeEach(() => {
wrapper = shallow(<VizTypeControl {...defaultProps} />);
});
it('renders a Modal', () => {
expect(wrapper.find(Modal)).to.have.lengthOf(1);
});
it('calls onChange when toggled', () => {
const select = wrapper.find('.viztype-selector-container').first();
select.simulate('click');
expect(defaultProps.onChange.called).to.equal(true);
});
it('filters images based on text input', () => {
expect(wrapper.find('img').length).to.be.above(20);
wrapper.setState({ filter: 'time' });
expect(wrapper.find('img').length).to.be.below(10);
});
});