mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
rewrite search key type check to be a var instead of a function
This commit is contained in:
parent
d2e335c7c5
commit
9605d8049d
@ -7,7 +7,7 @@ describe('<DataListToolbar />', () => {
|
||||
|
||||
const QS_CONFIG = {
|
||||
namespace: 'organization',
|
||||
dateFields: [ 'modified', 'created' ],
|
||||
dateFields: ['modified', 'created'],
|
||||
defaultParams: { page: 1, page_size: 5, order_by: 'name' },
|
||||
integerFields: ['page', 'page_size'],
|
||||
};
|
||||
|
@ -114,9 +114,9 @@ class Search extends React.Component {
|
||||
const { searchKey, searchValue } = this.state;
|
||||
const { onSearch, qsConfig } = this.props;
|
||||
|
||||
const isNonStringField = key =>
|
||||
qsConfig.integerFields.filter(field => field === key).length ||
|
||||
qsConfig.dateFields.filter(field => field === key).length;
|
||||
const isNonStringField =
|
||||
qsConfig.integerFields.filter(field => field === searchKey).length ||
|
||||
qsConfig.dateFields.filter(field => field === searchKey).length;
|
||||
|
||||
// TODO: this will probably become more sophisticated, where date
|
||||
// fields and string fields are passed to a formatter
|
||||
|
@ -7,7 +7,7 @@ describe('<Search />', () => {
|
||||
|
||||
const QS_CONFIG = {
|
||||
namespace: 'organization',
|
||||
dateFields: [ 'modified', 'created' ],
|
||||
dateFields: ['modified', 'created'],
|
||||
defaultParams: { page: 1, page_size: 5, order_by: 'name' },
|
||||
integerFields: ['page', 'page_size'],
|
||||
};
|
||||
@ -29,7 +29,12 @@ describe('<Search />', () => {
|
||||
const onSearch = jest.fn();
|
||||
|
||||
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';
|
||||
@ -46,7 +51,12 @@ describe('<Search />', () => {
|
||||
];
|
||||
const onSearch = jest.fn();
|
||||
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');
|
||||
expect(wrapper.state('isSearchDropdownOpen')).toEqual(false);
|
||||
wrapper.instance().handleDropdownToggle(true);
|
||||
@ -65,7 +75,12 @@ describe('<Search />', () => {
|
||||
];
|
||||
const onSearch = jest.fn();
|
||||
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');
|
||||
expect(wrapper.state('searchKey')).toEqual('name');
|
||||
wrapper
|
||||
|
@ -65,7 +65,7 @@ describe('<OrganizationTeams />', () => {
|
||||
expect(list.prop('itemCount')).toEqual(listData.data.count);
|
||||
expect(list.prop('qsConfig')).toEqual({
|
||||
namespace: 'team',
|
||||
dateFields: [ 'modified', 'created' ],
|
||||
dateFields: ['modified', 'created'],
|
||||
defaultParams: {
|
||||
page: 1,
|
||||
page_size: 5,
|
||||
|
@ -78,7 +78,7 @@ describe('qs (qs.js)', () => {
|
||||
test('should get default QS config object', () => {
|
||||
expect(getQSConfig('organization')).toEqual({
|
||||
namespace: 'organization',
|
||||
dateFields: [ 'modified', 'created' ],
|
||||
dateFields: ['modified', 'created'],
|
||||
defaultParams: { page: 1, page_size: 5, order_by: 'name' },
|
||||
integerFields: ['page', 'page_size'],
|
||||
});
|
||||
@ -95,7 +95,7 @@ describe('qs (qs.js)', () => {
|
||||
};
|
||||
expect(getQSConfig('inventory', defaults)).toEqual({
|
||||
namespace: 'inventory',
|
||||
dateFields: [ 'modified', 'created' ],
|
||||
dateFields: ['modified', 'created'],
|
||||
defaultParams: { page: 1, page_size: 15 },
|
||||
integerFields: ['page', 'page_size'],
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user