Skip to content

Commit

Permalink
fix lint issue
Browse files Browse the repository at this point in the history
  • Loading branch information
eokoneyo committed Nov 6, 2024
1 parent b20af88 commit 8a9f50a
Showing 1 changed file with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* 2.0.
*/

import { act, renderHook } from '@testing-library/react-hooks';
import { renderHook } from '@testing-library/react-hooks';
import { waitFor } from '@testing-library/react';
import {
useKnowledgeBaseIndices,
UseKnowledgeBaseIndicesParams,
Expand Down Expand Up @@ -48,10 +49,8 @@ describe('useKnowledgeBaseIndices', () => {
});

it('should call api to get knowledge base indices', async () => {
await act(async () => {
const { waitForNextUpdate } = renderHook(() => useKnowledgeBaseIndices(defaultProps));
await waitForNextUpdate();

renderHook(() => useKnowledgeBaseIndices(defaultProps));
await waitFor(() => {
expect(defaultProps.http.fetch).toHaveBeenCalledWith(
'/internal/elastic_assistant/knowledge_base/_indices',
{
Expand All @@ -65,20 +64,17 @@ describe('useKnowledgeBaseIndices', () => {
});

it('should return indices response', async () => {
await act(async () => {
const { result, waitForNextUpdate } = renderHook(() => useKnowledgeBaseIndices(defaultProps));
await waitForNextUpdate();

await expect(result.current).resolves.toStrictEqual(indicesResponse);
const { result } = renderHook(() => useKnowledgeBaseIndices(defaultProps));
await waitFor(() => {
expect(result.current).resolves.toStrictEqual(indicesResponse);
});
});

it('should display error toast when api throws error', async () => {
getKnowledgeBaseIndicesMock.mockRejectedValue(new Error('this is an error'));
await act(async () => {
const { waitForNextUpdate } = renderHook(() => useKnowledgeBaseIndices(defaultProps));
await waitForNextUpdate();

renderHook(() => useKnowledgeBaseIndices(defaultProps));
await waitFor(() => {
expect(toasts.addError).toHaveBeenCalled();
});
});
Expand Down

0 comments on commit 8a9f50a

Please sign in to comment.