Skip to content

Commit

Permalink
UIIN-2669: fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
UladzislauKutarkin committed May 10, 2024
1 parent a568dd6 commit 53df12a
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/edit/common/LocationSelectionWithCheck.test.js
@@ -1,11 +1,13 @@
import React from 'react';

import {
screen,
act,
} from '@folio/jest-config-stripes/testing-library/react';
import { fireEvent } from '@folio/jest-config-stripes/testing-library/dom';
import { LocationSelectionWithCheck } from './LocationSelectionWithCheck';

import '../../../test/jest/__mock__';
import { LocationSelectionWithCheck } from './LocationSelectionWithCheck';
import { renderWithFinalForm, renderWithIntl } from '../../../test/jest/helpers';
import renderWithRouter from '../../../test/jest/helpers/renderWithRouter';

Expand All @@ -19,11 +21,20 @@ jest.mock('../../RemoteStorageService', () => ({
},
}));

jest.mock('@folio/stripes/smart-components', () => ({ ...jest.requireActual('@folio/stripes/smart-components'),
LocationSelection: (props) => {
const { onSelect, resources } = props;
return (<button type="button" data-testid="selection-id" onClick={() => onSelect(resources.locations.records)}>LocationSelection</button>);
} }));
jest.mock('@folio/stripes/smart-components', () => (
{ ...jest.requireActual('@folio/stripes/smart-components'),
LocationSelection: (props) => {
const { onSelect, resources } = props;
return (
<button
type="button"
data-testid="selection-id"
onClick={() => onSelect(resources.locations.records)}
>
LocationSelection
</button>
);
} }));

const inputMock = {
value: 'test',
Expand Down Expand Up @@ -64,6 +75,7 @@ describe('LocationSelectionWithCheck', () => {
act(() => fireEvent.click(screen.getByTestId('selection-id')));

fireEvent.click(confirmButton);
expect(inputMock.onChange).toHaveBeenCalled();
});

it('render with selected location and cancel changes', async () => {
Expand All @@ -76,5 +88,6 @@ describe('LocationSelectionWithCheck', () => {
act(() => fireEvent.click(screen.getByTestId('selection-id')));

fireEvent.click(cancelButton);
expect(inputMock.onChange).not.toHaveBeenCalled();
});
});

0 comments on commit 53df12a

Please sign in to comment.