Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions superset-frontend/src/components/Select/AsyncSelect.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,34 @@ test('does not fire onChange when searching but no selection', async () => {
expect(onChange).toHaveBeenCalledTimes(1);
});

test('fires onChange when clearing the selection in single mode', async () => {
const onChange = jest.fn();
render(
<AsyncSelect
{...defaultProps}
onChange={onChange}
mode="single"
value={OPTIONS[0]}
/>,
);
clearAll();
expect(onChange).toHaveBeenCalledTimes(1);
});

test('fires onChange when clearing the selection in multiple mode', async () => {
const onChange = jest.fn();
render(
<AsyncSelect
{...defaultProps}
onChange={onChange}
mode="multiple"
value={OPTIONS[0]}
/>,
);
clearAll();
expect(onChange).toHaveBeenCalledTimes(1);
});

test('does not duplicate options when using numeric values', async () => {
render(
<AsyncSelect
Expand Down
28 changes: 28 additions & 0 deletions superset-frontend/src/components/Select/Select.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,34 @@ test('does not fire onChange when searching but no selection', async () => {
expect(onChange).toHaveBeenCalledTimes(1);
});

test('fires onChange when clearing the selection in single mode', async () => {
const onChange = jest.fn();
render(
<Select
{...defaultProps}
onChange={onChange}
mode="single"
value={OPTIONS[0]}
/>,
);
clearAll();
expect(onChange).toHaveBeenCalledTimes(1);
});

test('fires onChange when clearing the selection in multiple mode', async () => {
const onChange = jest.fn();
render(
<Select
{...defaultProps}
onChange={onChange}
mode="multiple"
value={OPTIONS[0]}
/>,
);
clearAll();
expect(onChange).toHaveBeenCalledTimes(1);
});

test('does not duplicate options when using numeric values', async () => {
render(
<Select
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ const Select = forwardRef(
: option.value,
),
);
fireOnChange();
}
fireOnChange();
};

const handleOnDeselect: SelectProps['onDeselect'] = (value, option) => {
Expand Down