Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/hooks/useLoadSubInstances.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from 'react';
import {
QueryClient,
QueryClientProvider,
} from 'react-query';
import { renderHook } from '@testing-library/react-hooks';

import '../../test/jest/__mock__';

import { useOkapiKy } from '@folio/stripes/core';

import { instances } from '../../test/fixtures';
import useLoadSubInstances from './useLoadSubInstances';

const queryClient = new QueryClient();
const wrapper = ({ children }) => (
<QueryClientProvider client={queryClient}>
{children}
</QueryClientProvider>
);

describe('useLoadSubInstances', () => {
let mock;
beforeEach(() => {
mock = useOkapiKy.mockClear().mockReturnValue({
get: () => ({
json: () => ({ instances }),
}),
});
});

afterEach(() => {
mock.mockRestore();
});

it('returns an empty array when given an empty array of instance ids', () => {
const { result } = renderHook(() => useLoadSubInstances(instances.map(({ id }) => id)), { wrapper });
expect(result.current).toEqual([]);
});
});