mirror of
https://github.com/apache/superset.git
synced 2026-04-26 11:34:27 +00:00
refactor(frontend): migrate 6 Enzyme-based tests to RTL, part 2 (#30281)
Signed-off-by: hainenber <dotronghai96@gmail.com>
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
* under the License.
|
||||
*/
|
||||
import { isValidElement } from 'react';
|
||||
import { styledMount as mount } from 'spec/helpers/theming';
|
||||
import { render } from 'spec/helpers/testing-library';
|
||||
import ColumnElement from 'src/SqlLab/components/ColumnElement';
|
||||
import { mockedActions, table } from 'src/SqlLab/fixtures';
|
||||
|
||||
@@ -30,19 +30,25 @@ describe('ColumnElement', () => {
|
||||
expect(isValidElement(<ColumnElement {...mockedProps} />)).toBe(true);
|
||||
});
|
||||
it('renders a proper primary key', () => {
|
||||
const wrapper = mount(<ColumnElement column={table.columns[0]} />);
|
||||
expect(wrapper.find('i.fa-key')).toExist();
|
||||
expect(wrapper.find('.col-name').first().text()).toBe('id');
|
||||
const { container } = render(<ColumnElement column={table.columns[0]} />);
|
||||
expect(container.querySelector('i.fa-key')).toBeInTheDocument();
|
||||
expect(container.querySelector('.col-name')?.firstChild).toHaveTextContent(
|
||||
'id',
|
||||
);
|
||||
});
|
||||
it('renders a multi-key column', () => {
|
||||
const wrapper = mount(<ColumnElement column={table.columns[1]} />);
|
||||
expect(wrapper.find('i.fa-link')).toExist();
|
||||
expect(wrapper.find('i.fa-bookmark')).toExist();
|
||||
expect(wrapper.find('.col-name').first().text()).toBe('first_name');
|
||||
const { container } = render(<ColumnElement column={table.columns[1]} />);
|
||||
expect(container.querySelector('i.fa-link')).toBeInTheDocument();
|
||||
expect(container.querySelector('i.fa-bookmark')).toBeInTheDocument();
|
||||
expect(container.querySelector('.col-name')?.firstChild).toHaveTextContent(
|
||||
'first_name',
|
||||
);
|
||||
});
|
||||
it('renders a column with no keys', () => {
|
||||
const wrapper = mount(<ColumnElement column={table.columns[2]} />);
|
||||
expect(wrapper.find('i')).not.toExist();
|
||||
expect(wrapper.find('.col-name').first().text()).toBe('last_name');
|
||||
const { container } = render(<ColumnElement column={table.columns[2]} />);
|
||||
expect(container.querySelector('i')).not.toBeInTheDocument();
|
||||
expect(container.querySelector('.col-name')?.firstChild).toHaveTextContent(
|
||||
'last_name',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user