Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Jul 27, 2021
1 parent 3ad198b commit 2c58e4d
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions superset-frontend/src/views/CRUD/alert/AlertReportModal.test.jsx
Expand Up @@ -36,7 +36,7 @@ const mockData = {
id: 1,
name: 'test report',
description: 'test report description',
chart: { id: 1, slice_name: 'test chart' },
chart: { id: 1, slice_name: 'test chart', viz_type: 'table' },
database: { id: 1, database_name: 'test database' },
sql: 'SELECT NaN',
};
Expand Down Expand Up @@ -76,7 +76,7 @@ fetchMock.get(dashboardEndpoint, {
});

fetchMock.get(chartEndpoint, {
result: [],
result: [{ text: 'table chart', value: 1 }],
});

async function mountAndWait(props = mockedProps) {
Expand Down Expand Up @@ -260,6 +260,22 @@ describe('AlertReportModal', () => {
expect(wrapper.find(Radio)).toHaveLength(2);
});

it('renders text option for text-based charts', async () => {
const props = {
...mockedProps,
alert: mockData,
};
const textWrapper = await mountAndWait(props);

const chartOption = textWrapper.find('input[value="chart"]');
act(() => {
chartOption.props().onChange({ target: { value: 'chart' } });
});
await waitForComponentToPaint(textWrapper);

expect(textWrapper.find('input[value="TEXT"]')).toExist();
});

it('renders input element for working timeout', () => {
expect(wrapper.find('input[name="working_timeout"]')).toExist();
});
Expand Down

0 comments on commit 2c58e4d

Please sign in to comment.