Skip to content

Commit

Permalink
Blocks save event filter with a white space name
Browse files Browse the repository at this point in the history
  • Loading branch information
dasansol92 committed Jun 8, 2021
1 parent c1924c3 commit 3c9226c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,23 @@ describe('Event filter form', () => {
expect(store.getState()!.management!.eventFilters!.form!.hasNameError).toBeFalsy();
});

it('should change name with a white space still shows an error', async () => {
component = renderComponentWithdata();

const nameInput = component.getByPlaceholderText(NAME_PLACEHOLDER);

act(() => {
fireEvent.change(nameInput, {
target: {
value: ' ',
},
});
});

expect(store.getState()!.management!.eventFilters!.form!.entry!.name).toBe('');
expect(store.getState()!.management!.eventFilters!.form!.hasNameError).toBeTruthy();
});

it('should change comments', async () => {
component = renderComponentWithdata();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,12 @@ export const EventFiltersForm: React.FC<EventFiltersFormProps> = memo(
const handleOnChangeName = useCallback(
(e: React.ChangeEvent<HTMLInputElement>) => {
if (!exception) return;
const name = e.target.value.toString().trim();
dispatch({
type: 'eventFiltersChangeForm',
payload: {
entry: { ...exception, name: e.target.value.toString() },
hasNameError: !e.target.value,
entry: { ...exception, name },
hasNameError: !name,
},
});
},
Expand Down

0 comments on commit 3c9226c

Please sign in to comment.