Skip to content

Commit 492e7e4

Browse files
committed
update typescript version
1 parent aa01f36 commit 492e7e4

File tree

4 files changed

+35
-11
lines changed

4 files changed

+35
-11
lines changed

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/module/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@
5555
"react-router": "^6.30.1",
5656
"react-router-dom": "^6.30.1",
5757
"rimraf": "^6.0.1",
58-
"typescript": "^5.4.5"
58+
"typescript": "^5.8.3"
5959
}
6060
}

packages/module/src/DataViewFilters/DataViewFilters.test.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { render } from '@testing-library/react';
2+
import { render, fireEvent } from '@testing-library/react';
33
import DataViewFilters from './DataViewFilters';
44
import DataViewToolbar from '../DataViewToolbar';
55
import DataViewTextFilter from '../DataViewTextFilter';
@@ -18,4 +18,28 @@ describe('DataViewFilters component', () => {
1818
/>);
1919
expect(container).toMatchSnapshot();
2020
});
21+
22+
it('should call onChange with correct key and value when filter changes', () => {
23+
const mockOnChange = jest.fn();
24+
const { getByLabelText } = render(
25+
<DataViewToolbar
26+
filters={
27+
<DataViewFilters onChange={mockOnChange} values={{}}>
28+
<DataViewTextFilter filterId="one" title="One" />
29+
<DataViewTextFilter filterId="two" title="Two" />
30+
</DataViewFilters>
31+
}
32+
/>
33+
);
34+
const input = getByLabelText('One filter');
35+
// Simulate user typing 'abc' in the input
36+
input.focus();
37+
// fireEvent.change triggers the onChange handler of the input
38+
// The SearchInput component expects the value as the second argument
39+
// so we use fireEvent.change with { target: { value: 'abc' } }
40+
// but since SearchInput is a custom component, we use fireEvent.input
41+
// to trigger the native input event
42+
fireEvent.input(input, { target: { value: 'abc' } });
43+
expect(mockOnChange).toHaveBeenCalledWith('one', { one: 'abc' });
44+
});
2145
});

packages/module/src/DataViewFilters/DataViewFilters.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export const DataViewFilters = <T extends object>({
130130
value: unknown;
131131
}>, {
132132
showToolbarItem: activeAttributeMenu === child.props.title,
133-
onChange: (event, value) => onChange?.(event, { [child.props.filterId]: value } as Partial<T>),
133+
onChange: (event, value) => onChange?.(child.props.filterId, { [child.props.filterId]: value } as Partial<T>),
134134
value: values?.[child.props.filterId],
135135
...child.props
136136
})

0 commit comments

Comments
 (0)