mirror of
https://github.com/apache/superset.git
synced 2026-04-20 08:34:37 +00:00
* Bumping react==16.4.1 & enzyme==3.3.0 The upgrade was pretty smooth except for a cryptic message coming out of react-select around running multiple copies of React. It turns out the `common` bundle had React and was conflicting with explore and dashboard apps, only in 16.x. This somehow wasn't a problem in 15.x outside of the wasted resources. Running 16.4 should bring in all sorts of perf improvements and features we've all been waiting for. https://reactjs.org/blog/2017/09/26/react-v16.0.html TODO: react-bootstrap-datetimepicker isn't compatible with React 16 * Trying to deprecate react-bootstrap-datetime * Moving forward * Reintroducing tests
62 lines
2.2 KiB
JavaScript
62 lines
2.2 KiB
JavaScript
import React from 'react';
|
|
import { mount, shallow } from 'enzyme';
|
|
import { describe, it } from 'mocha';
|
|
import { expect } from 'chai';
|
|
|
|
import Link from '../../../src/SqlLab/components/Link';
|
|
import TableElement from '../../../src/SqlLab/components/TableElement';
|
|
import ColumnElement from '../../../src/SqlLab/components/ColumnElement';
|
|
import { mockedActions, table } from './fixtures';
|
|
|
|
describe('TableElement', () => {
|
|
const mockedProps = {
|
|
actions: mockedActions,
|
|
table,
|
|
timeout: 0,
|
|
};
|
|
it('renders', () => {
|
|
expect(
|
|
React.isValidElement(<TableElement />),
|
|
).to.equal(true);
|
|
});
|
|
it('renders with props', () => {
|
|
expect(
|
|
React.isValidElement(<TableElement {...mockedProps} />),
|
|
).to.equal(true);
|
|
});
|
|
it('has 2 Link elements', () => {
|
|
const wrapper = shallow(<TableElement {...mockedProps} />);
|
|
expect(wrapper.find(Link)).to.have.length(2);
|
|
});
|
|
it('has 14 columns', () => {
|
|
const wrapper = shallow(<TableElement {...mockedProps} />);
|
|
expect(wrapper.find(ColumnElement)).to.have.length(14);
|
|
});
|
|
it('mounts', () => {
|
|
mount(<TableElement {...mockedProps} />);
|
|
});
|
|
it('sorts columns', () => {
|
|
const wrapper = shallow(<TableElement {...mockedProps} />);
|
|
expect(wrapper.state().sortColumns).to.equal(false);
|
|
expect(wrapper.find(ColumnElement).first().props().column.name).to.equal('id');
|
|
wrapper.find('.sort-cols').simulate('click');
|
|
expect(wrapper.state().sortColumns).to.equal(true);
|
|
expect(wrapper.find(ColumnElement).first().props().column.name).to.equal('last_login');
|
|
});
|
|
it('calls the collapseTable action', () => {
|
|
const wrapper = mount(<TableElement {...mockedProps} />);
|
|
expect(mockedActions.collapseTable.called).to.equal(false);
|
|
wrapper.find('.table-name').simulate('click');
|
|
expect(mockedActions.collapseTable.called).to.equal(true);
|
|
});
|
|
it('removes the table', () => {
|
|
const wrapper = shallow(<TableElement {...mockedProps} />);
|
|
expect(wrapper.state().expanded).to.equal(true);
|
|
wrapper.find('.table-remove').simulate('click');
|
|
expect(wrapper.state().expanded).to.equal(false);
|
|
setTimeout(() => {
|
|
expect(mockedActions.removeTable.called).to.equal(true);
|
|
}, 10);
|
|
});
|
|
});
|