mirror of
https://github.com/ansible/awx.git
synced 2026-07-04 04:48:02 -02:30
rewrite search key type check to be a var instead of a function
This commit is contained in:
@@ -114,9 +114,9 @@ class Search extends React.Component {
|
|||||||
const { searchKey, searchValue } = this.state;
|
const { searchKey, searchValue } = this.state;
|
||||||
const { onSearch, qsConfig } = this.props;
|
const { onSearch, qsConfig } = this.props;
|
||||||
|
|
||||||
const isNonStringField = key =>
|
const isNonStringField =
|
||||||
qsConfig.integerFields.filter(field => field === key).length ||
|
qsConfig.integerFields.filter(field => field === searchKey).length ||
|
||||||
qsConfig.dateFields.filter(field => field === key).length;
|
qsConfig.dateFields.filter(field => field === searchKey).length;
|
||||||
|
|
||||||
// TODO: this will probably become more sophisticated, where date
|
// TODO: this will probably become more sophisticated, where date
|
||||||
// fields and string fields are passed to a formatter
|
// fields and string fields are passed to a formatter
|
||||||
|
|||||||
@@ -29,7 +29,12 @@ describe('<Search />', () => {
|
|||||||
const onSearch = jest.fn();
|
const onSearch = jest.fn();
|
||||||
|
|
||||||
search = mountWithContexts(
|
search = mountWithContexts(
|
||||||
<Search qsConfig={QS_CONFIG} sortedColumnKey="name" columns={columns} onSearch={onSearch} />
|
<Search
|
||||||
|
qsConfig={QS_CONFIG}
|
||||||
|
sortedColumnKey="name"
|
||||||
|
columns={columns}
|
||||||
|
onSearch={onSearch}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
search.find(searchTextInput).instance().value = 'test-321';
|
search.find(searchTextInput).instance().value = 'test-321';
|
||||||
@@ -46,7 +51,12 @@ describe('<Search />', () => {
|
|||||||
];
|
];
|
||||||
const onSearch = jest.fn();
|
const onSearch = jest.fn();
|
||||||
const wrapper = mountWithContexts(
|
const wrapper = mountWithContexts(
|
||||||
<Search qsConfig={QS_CONFIG} sortedColumnKey="name" columns={columns} onSearch={onSearch} />
|
<Search
|
||||||
|
qsConfig={QS_CONFIG}
|
||||||
|
sortedColumnKey="name"
|
||||||
|
columns={columns}
|
||||||
|
onSearch={onSearch}
|
||||||
|
/>
|
||||||
).find('Search');
|
).find('Search');
|
||||||
expect(wrapper.state('isSearchDropdownOpen')).toEqual(false);
|
expect(wrapper.state('isSearchDropdownOpen')).toEqual(false);
|
||||||
wrapper.instance().handleDropdownToggle(true);
|
wrapper.instance().handleDropdownToggle(true);
|
||||||
@@ -65,7 +75,12 @@ describe('<Search />', () => {
|
|||||||
];
|
];
|
||||||
const onSearch = jest.fn();
|
const onSearch = jest.fn();
|
||||||
const wrapper = mountWithContexts(
|
const wrapper = mountWithContexts(
|
||||||
<Search qsConfig={QS_CONFIG} sortedColumnKey="name" columns={columns} onSearch={onSearch} />
|
<Search
|
||||||
|
qsConfig={QS_CONFIG}
|
||||||
|
sortedColumnKey="name"
|
||||||
|
columns={columns}
|
||||||
|
onSearch={onSearch}
|
||||||
|
/>
|
||||||
).find('Search');
|
).find('Search');
|
||||||
expect(wrapper.state('searchKey')).toEqual('name');
|
expect(wrapper.state('searchKey')).toEqual('name');
|
||||||
wrapper
|
wrapper
|
||||||
|
|||||||
Reference in New Issue
Block a user