@elastic-suite/gally-admin-components
Version:
Components package for gally admin BO
46 lines (43 loc) • 1.23 kB
text/typescript
import { resourceWithRef } from '@elastic-suite/gally-admin-shared'
import sourceFields from '../../public/mocks/source_fields.json'
import { renderHookWithProviders } from '../utils/tests'
import { useApiFilters } from './useApiFilters'
describe('useApiFilters', () => {
it('should return the filters from a resource', () => {
const { result } = renderHookWithProviders(() =>
useApiFilters(sourceFields, resourceWithRef)
)
expect(result.current).toEqual([
expect.objectContaining({
id: 'code',
label: 'Attribute code',
multiple: false,
type: 'string',
}),
expect.objectContaining({
id: 'defaultLabel',
label: 'Attribute label',
multiple: false,
type: 'string',
}),
expect.objectContaining({
id: 'type',
label: 'Attribute type',
multiple: false,
type: 'string',
}),
expect.objectContaining({
id: 'isFilterable',
label: 'Filterable',
multiple: false,
type: 'boolean',
}),
expect.objectContaining({
id: 'isSearchable',
label: 'Searchable',
multiple: false,
type: 'boolean',
}),
])
})
})