mirror of
https://github.com/apache/superset.git
synced 2026-04-20 16:44:46 +00:00
committed by
GitHub
parent
0fc9da6be7
commit
0c08bb87c3
@@ -160,9 +160,13 @@ describe('AlteredSliceTag', () => {
|
||||
);
|
||||
const rows = getTableWrapperFromModalBody(modalBody).find('tr');
|
||||
expect(rows).toHaveLength(8);
|
||||
const fakeRow = mount(<div>{rows.get(1)}</div>);
|
||||
expect(fakeRow.find('tr')).toHaveLength(1);
|
||||
expect(fakeRow.find('td')).toHaveLength(3);
|
||||
const slice = mount(
|
||||
<table>
|
||||
<tbody>{rows.get(1)}</tbody>
|
||||
</table>,
|
||||
);
|
||||
expect(slice.find('tr')).toHaveLength(1);
|
||||
expect(slice.find('td')).toHaveLength(3);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import Button from 'src/components/Button';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { supersetTheme, ThemeProvider } from '@superset-ui/core';
|
||||
import ConfirmStatusChange from 'src/components/ConfirmStatusChange';
|
||||
import Modal from 'src/common/components/Modal';
|
||||
@@ -44,7 +45,9 @@ describe('ConfirmStatusChange', () => {
|
||||
);
|
||||
|
||||
it('opens a confirm modal', () => {
|
||||
wrapper.find('#btn1').first().props().onClick('foo');
|
||||
act(() => {
|
||||
wrapper.find('#btn1').first().props().onClick('foo');
|
||||
});
|
||||
|
||||
wrapper.update();
|
||||
|
||||
@@ -52,7 +55,9 @@ describe('ConfirmStatusChange', () => {
|
||||
});
|
||||
|
||||
it('calls the function on confirm', () => {
|
||||
wrapper.find(Button).last().props().onClick();
|
||||
act(() => {
|
||||
wrapper.find(Button).last().props().onClick();
|
||||
});
|
||||
|
||||
expect(mockedProps.onConfirm).toHaveBeenCalledWith('foo');
|
||||
});
|
||||
|
||||
@@ -150,37 +150,40 @@ describe('ListView', () => {
|
||||
|
||||
it('calls fetchData on mount', () => {
|
||||
expect(wrapper.find(ListView)).toExist();
|
||||
expect(mockedProps.fetchData.mock.calls[0]).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"filters": Array [],
|
||||
"pageIndex": 0,
|
||||
"pageSize": 1,
|
||||
"sortBy": Array [],
|
||||
},
|
||||
]
|
||||
`);
|
||||
expect(mockedProps.fetchData.mock.calls[0]).toMatchInlineSnapshot(
|
||||
`
|
||||
Array [
|
||||
Object {
|
||||
"filters": Array [],
|
||||
"pageIndex": 0,
|
||||
"pageSize": 1,
|
||||
"sortBy": Array [],
|
||||
},
|
||||
]
|
||||
`,
|
||||
);
|
||||
});
|
||||
|
||||
it('calls fetchData on sort', () => {
|
||||
wrapper.find('[data-test="sort-header"]').at(1).simulate('click');
|
||||
|
||||
expect(mockedProps.fetchData).toHaveBeenCalled();
|
||||
expect(mockedProps.fetchData.mock.calls[0]).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
Object {
|
||||
"filters": Array [],
|
||||
"pageIndex": 0,
|
||||
"pageSize": 1,
|
||||
"sortBy": Array [
|
||||
Object {
|
||||
"desc": false,
|
||||
"id": "id",
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
`);
|
||||
expect(mockedProps.fetchData.mock.calls[0]).toMatchInlineSnapshot(
|
||||
`
|
||||
Array [
|
||||
Object {
|
||||
"filters": Array [],
|
||||
"pageIndex": 0,
|
||||
"pageSize": 1,
|
||||
"sortBy": Array [
|
||||
Object {
|
||||
"desc": false,
|
||||
"id": "id",
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
`,
|
||||
);
|
||||
});
|
||||
|
||||
it('renders pagination controls', () => {
|
||||
@@ -363,13 +366,14 @@ describe('ListView', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('renders and empty state when there is no data', () => {
|
||||
it('renders and empty state when there is no data', async () => {
|
||||
const props = {
|
||||
...mockedProps,
|
||||
data: [],
|
||||
};
|
||||
|
||||
const wrapper2 = factory(props);
|
||||
await waitForComponentToPaint(wrapper2);
|
||||
expect(wrapper2.find(Empty)).toExist();
|
||||
});
|
||||
|
||||
@@ -461,7 +465,7 @@ describe('ListView', () => {
|
||||
initialSort: [{ id: 'something' }],
|
||||
});
|
||||
|
||||
act(() => {
|
||||
await act(async () => {
|
||||
wrapper2.find('[data-test="card-sort-select"]').first().props().onChange({
|
||||
desc: false,
|
||||
id: 'something',
|
||||
@@ -470,7 +474,6 @@ describe('ListView', () => {
|
||||
});
|
||||
});
|
||||
|
||||
wrapper2.update();
|
||||
expect(mockedProps.fetchData).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -23,10 +23,13 @@ import { Provider } from 'react-redux';
|
||||
import configureStore from 'redux-mock-store';
|
||||
import SupersetResourceSelect from 'src/components/SupersetResourceSelect';
|
||||
import { supersetTheme, ThemeProvider } from '@superset-ui/core';
|
||||
import fetchMock from 'fetch-mock';
|
||||
|
||||
describe('SupersetResourceSelect', () => {
|
||||
const NOOP = () => {};
|
||||
|
||||
fetchMock.get('glob:*/api/v1/dataset/?q=*', {});
|
||||
|
||||
it('is a valid element', () => {
|
||||
// @ts-ignore
|
||||
expect(
|
||||
|
||||
Reference in New Issue
Block a user