Skip to content

Commit 768ed97

Browse files
rtexelmpull[bot]
authored andcommitted
chore(superset-ui-core and NoResultsComponent): Migrate to RTL, add RTL modules to the ui-core (#28187)
1 parent e550cd4 commit 768ed97

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

superset-frontend/packages/superset-ui-core/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@
7373
"@emotion/cache": "^11.4.0",
7474
"@emotion/react": "^11.4.1",
7575
"@emotion/styled": "^11.3.0",
76+
"@testing-library/dom": "^7.29.4",
77+
"@testing-library/jest-dom": "^5.11.6",
78+
"@testing-library/react": "^11.2.0",
79+
"@testing-library/user-event": "^12.7.0",
7680
"@types/react": "*",
7781
"@types/react-loadable": "*",
7882
"@types/tinycolor2": "*",

superset-frontend/packages/superset-ui-core/test/chart/components/NoResultsComponent.test.tsx

+17-10
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,25 @@
1818
*/
1919

2020
import React from 'react';
21-
import { shallow } from 'enzyme';
22-
import { configure } from '@superset-ui/core';
21+
import { render, screen } from '@testing-library/react';
22+
import '@testing-library/jest-dom';
23+
import { ThemeProvider, supersetTheme } from '../../../src/style';
2324
import NoResultsComponent from '../../../src/chart/components/NoResultsComponent';
2425

25-
configure();
26+
const renderNoResultsComponent = () =>
27+
render(
28+
<ThemeProvider theme={supersetTheme}>
29+
<NoResultsComponent height="400" width="300" />
30+
</ThemeProvider>,
31+
);
2632

27-
describe('NoResultsComponent', () => {
28-
it('renders the no results error', () => {
29-
const wrapper = shallow(<NoResultsComponent height="400" width="300" />);
33+
test('renders the no results error', () => {
34+
renderNoResultsComponent();
3035

31-
expect(wrapper.text()).toEqual(
32-
'No ResultsNo results were returned for this query. If you expected results to be returned, ensure any filters are configured properly and the datasource contains data for the selected time range.',
33-
);
34-
});
36+
expect(screen.getByText(/No Results/)).toBeInTheDocument();
37+
expect(
38+
screen.getByText(
39+
'No results were returned for this query. If you expected results to be returned, ensure any filters are configured properly and the datasource contains data for the selected time range.',
40+
),
41+
).toBeInTheDocument();
3542
});

0 commit comments

Comments
 (0)