Skip to content

Commit

Permalink
test: add test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
alisher-epam committed Oct 25, 2024
1 parent fe3f9c4 commit fc8fe8b
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { renderHook } from '@testing-library/react-hooks';

import { useReceivingTenantIdsAndLocations } from './useReceivingTenantIdsAndLocations';

jest.mock('../consortia', () => ({
useCurrentUserTenants: jest.fn(() => [{ id: 'central' }, { id: 'college' }]),
}));

describe('useReceivingTenantIdsAndLocations', () => {
it('should return receivingTenantIds', () => {
const tenants = ['central', 'college'];
const { result } = renderHook(() => useReceivingTenantIdsAndLocations({
receivingTenantIds: tenants,
currentReceivingTenantId: 'central',
}));

expect(result.current.receivingTenantIds).toEqual(tenants);
});

it('should return tenantId', () => {
const currentReceivingTenantId = 'central';

const { result } = renderHook(() => useReceivingTenantIdsAndLocations({ currentReceivingTenantId }));

expect(result.current.tenantId).toBe(currentReceivingTenantId);
});

it('should return additionalLocationIds', () => {
const { result } = renderHook(() => useReceivingTenantIdsAndLocations({}));

expect(result.current.additionalLocationIds).toEqual([]);
});
});

0 comments on commit fc8fe8b

Please sign in to comment.