[slices] add simple new slice form (#2800)

* initial structure for add new slice page

* simplify add slice form

* add a test

* fix long line

* use underscore for template name

* fix controls path

* fix vis types select
This commit is contained in:
Alanna Scott
2017-06-07 22:08:59 -07:00
committed by GitHub
parent 7c28e4eace
commit 5bf40e2256
6 changed files with 181 additions and 5 deletions

View File

@@ -0,0 +1,39 @@
import React from 'react';
import { expect } from 'chai';
import { describe, it, beforeEach } from 'mocha';
import { shallow } from 'enzyme';
import { Button } from 'react-bootstrap';
import Select from 'react-virtualized-select';
import AddSliceContainer from '../../../javascripts/addSlice/AddSliceContainer';
const defaultProps = {
datasources: [
{ label: 'my first table', value: '1__table' },
{ label: 'another great table', value: '2__table' },
],
};
describe('AddSliceContainer', () => {
let wrapper;
beforeEach(() => {
wrapper = shallow(<AddSliceContainer {...defaultProps} />);
});
it('uses table as default visType', () => {
expect(wrapper.state().visType).to.equal('table');
});
it('renders 2 selects', () => {
expect(wrapper.find(Select)).to.have.lengthOf(2);
});
it('renders a button', () => {
expect(wrapper.find(Button)).to.have.lengthOf(1);
});
it('formats explore url', () => {
const formattedUrl = '/superset/explore/table/1?form_data=%7B%22viz_type%22%3A%22table%22%7D';
expect(wrapper.instance().exploreUrl()).to.equal(formattedUrl);
});
});