mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
refactor: Refactor QueryTable to use react-table (#11216)
* Refactor QueryTable to use react-table * Fix lodash import * Fix tests * Fix imports and QuerySearch styles * Update superset-frontend/src/SqlLab/components/QuerySearch.jsx Co-authored-by: Evan Rusackas <evan@preset.io> * Update superset-frontend/src/SqlLab/components/QuerySearch.jsx Co-authored-by: Evan Rusackas <evan@preset.io> * Lint fix * Refactored QueryTable into functional component * Remove calculating content height * Lint fix Co-authored-by: Evan Rusackas <evan@preset.io>
This commit is contained in:
committed by
GitHub
parent
a1f8429b4e
commit
735123d1f5
@@ -21,7 +21,6 @@ import configureStore from 'redux-mock-store';
|
||||
import thunk from 'redux-thunk';
|
||||
|
||||
import { shallow } from 'enzyme';
|
||||
import sinon from 'sinon';
|
||||
|
||||
import App from 'src/SqlLab/components/App';
|
||||
import TabbedSqlEditors from 'src/SqlLab/components/TabbedSqlEditors';
|
||||
@@ -41,14 +40,6 @@ describe('SqlLab App', () => {
|
||||
expect(React.isValidElement(<App />)).toBe(true);
|
||||
});
|
||||
|
||||
it('should handler resize', () => {
|
||||
const inner = wrapper.dive();
|
||||
sinon.spy(inner.instance(), 'getHeight');
|
||||
inner.instance().handleResize();
|
||||
expect(inner.instance().getHeight.callCount).toBe(1);
|
||||
inner.instance().getHeight.restore();
|
||||
});
|
||||
|
||||
it('should render', () => {
|
||||
const inner = wrapper.dive();
|
||||
expect(inner.find('.SqlLab')).toHaveLength(1);
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
*/
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { Table } from 'reactable-arc';
|
||||
import QueryTable from 'src/SqlLab/components/QueryTable';
|
||||
|
||||
import TableView from 'src/components/TableView';
|
||||
import { TableCollection } from 'src/components/dataViewCommon';
|
||||
import { queries } from './fixtures';
|
||||
|
||||
describe('QueryTable', () => {
|
||||
@@ -35,10 +35,14 @@ describe('QueryTable', () => {
|
||||
});
|
||||
it('renders a proper table', () => {
|
||||
const wrapper = shallow(<QueryTable {...mockedProps} />);
|
||||
expect(wrapper.find(Table)).toExist();
|
||||
expect(wrapper.find(Table).shallow().find('table')).toExist();
|
||||
expect(wrapper.find(Table).shallow().find('table').find('Tr')).toHaveLength(
|
||||
2,
|
||||
);
|
||||
const tableWrapper = wrapper
|
||||
.find(TableView)
|
||||
.shallow()
|
||||
.find(TableCollection)
|
||||
.shallow();
|
||||
expect(wrapper.find(TableView)).toExist();
|
||||
expect(tableWrapper.find('table')).toExist();
|
||||
expect(tableWrapper.find('table').find('thead').find('tr')).toHaveLength(1);
|
||||
expect(tableWrapper.find('table').find('tbody').find('tr')).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user