@elastic-suite/gally-admin-components
Version:
Components package for gally admin BO
26 lines (21 loc) • 902 B
text/typescript
import { waitFor } from '@testing-library/react'
import {
fetchApi,
isVirtualCategoryEnabled,
} from '@elastic-suite/gally-admin-shared'
import { renderHookWithProviders } from '../utils/tests'
import { useRuleOperators } from './useRuleOperators'
describe('useRuleOperators', () => {
it('should load the rule operators', async () => {
;(fetchApi as jest.Mock).mockClear()
const { result } = renderHookWithProviders(() => useRuleOperators())
await waitFor(() => expect(result.current).toEqual(expect.any(Object)))
expect(fetchApi).toHaveBeenCalled()
})
it('should not load the rule operators if virtual category bundle is not enabled', () => {
;(fetchApi as jest.Mock).mockClear()
;(isVirtualCategoryEnabled as jest.Mock).mockImplementationOnce(() => false)
renderHookWithProviders(() => useRuleOperators())
expect(fetchApi).not.toHaveBeenCalled()
})
})