Skip to content

Commit

Permalink
Add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
codyml committed Jun 27, 2022
1 parent a5f287b commit dcc7fec
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
21 changes: 21 additions & 0 deletions superset-frontend/src/addSlice/AddSliceContainer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,27 @@ test('renders an enabled button if datasource and viz type are selected', async
).toHaveLength(0);
});

test('double-click viz type does nothing if no datasource is selected', async () => {
const wrapper = await getWrapper();
wrapper.instance().gotoSlice = jest.fn();
wrapper.update();
wrapper.instance().onVizTypeDoubleClick();
expect(wrapper.instance().gotoSlice).not.toBeCalled();
});

test('double-click viz type submits if datasource is selected', async () => {
const wrapper = await getWrapper();
wrapper.instance().gotoSlice = jest.fn();
wrapper.update();
wrapper.setState({
datasource,
visType: 'table',
});

wrapper.instance().onVizTypeDoubleClick();
expect(wrapper.instance().gotoSlice).toBeCalled();
});

test('formats Explore url', async () => {
const wrapper = await getWrapper();
wrapper.setState({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,22 @@ describe('VizTypeControl', () => {
within(visualizations).queryByText('Pie Chart'),
).not.toBeInTheDocument();
});

it('Submit on viz type double-click', () => {
renderWrapper();
userEvent.click(screen.getByRole('button', { name: 'ballot All charts' }));
const visualizations = screen.getByTestId(getTestId('viz-row'));
userEvent.click(
within(visualizations).getByText('Time-series Bar Chart v2'),
);

expect(defaultProps.onChange).not.toBeCalled();
userEvent.dblClick(
within(visualizations).getByText('Time-series Line Chart'),
);

expect(defaultProps.onChange).toHaveBeenCalledWith(
'echarts_timeseries_line',
);
});
});

0 comments on commit dcc7fec

Please sign in to comment.