From edfb1983e2c3880b24ed0c84c7364822e755eb8a Mon Sep 17 00:00:00 2001 From: Artem Blazhko Date: Thu, 5 Dec 2024 12:19:56 +0200 Subject: [PATCH] UIREQMED-64: Create a solution to not display "Are you sure?" when no changes have been made, increase code coverage (#79) --- CHANGELOG.md | 1 + src/components/ConfirmItem/ConfirmItem.js | 5 +- .../ConfirmItem/ConfirmItem.test.js | 28 ++++ .../components/RequestForm/RequestForm.js | 80 ++++++---- .../RequestForm/RequestForm.test.js | 3 +- .../SendItemInTransit/SendItemInTransit.js | 2 +- .../SendItemInTransit.test.js | 87 ++++++++++- ...ediatedRequestsActivitiesContainer.test.js | 142 ++++++++++++++---- src/utils.js | 6 +- src/utils.test.js | 27 ---- 10 files changed, 280 insertions(+), 101 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d88a0a..37af23c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 2.1.0 (IN PROGRESS) * Minor improvements and code fixes. Refs UIREQMED-65. +* Create a solution to not display "Are you sure?" modal when no changes have been made, increase code coverage. Refs UIREQMED-64. ## [2.0.0] (https://github.com/folio-org/ui-requests-mediated/tree/v2.0.0) (2024-11-30) [Full Changelog](https://github.com/folio-org/ui-requests-mediated/compare/v1.1.0...v2.0.0) diff --git a/src/components/ConfirmItem/ConfirmItem.js b/src/components/ConfirmItem/ConfirmItem.js index 93d8cce..0de6353 100644 --- a/src/components/ConfirmItem/ConfirmItem.js +++ b/src/components/ConfirmItem/ConfirmItem.js @@ -59,7 +59,10 @@ const ConfirmItem = ({ defaultWidth="fill" paneTitle={} > -
+ { @@ -104,4 +109,27 @@ describe('ConfirmItem', () => { contentData: basicProps.contentData, }), {}); }); + + describe('Form submitting', () => { + const submitEvent = { + stopPropagation: jest.fn(), + preventDefault: jest.fn(), + }; + + beforeEach(() => { + const confirmItemForm = screen.getByTestId(testIds.confirmItemForm); + + fireEvent.submit(confirmItemForm, submitEvent); + }); + + it('should handle data submitting', () => { + expect(basicProps.handleSubmit).toHaveBeenCalled(); + }); + + it('should reset item barcode', () => { + const expectedArgs = ['itemBarcode', '']; + + expect(basicProps.form.change).toHaveBeenCalledWith(...expectedArgs); + }); + }); }); diff --git a/src/components/MediatedRequestsActivities/components/RequestForm/RequestForm.js b/src/components/MediatedRequestsActivities/components/RequestForm/RequestForm.js index 04b84c7..cda92eb 100644 --- a/src/components/MediatedRequestsActivities/components/RequestForm/RequestForm.js +++ b/src/components/MediatedRequestsActivities/components/RequestForm/RequestForm.js @@ -2,7 +2,10 @@ import React from 'react'; import PropTypes from 'prop-types'; import { Field } from 'react-final-form'; import { FormattedMessage } from 'react-intl'; -import { isEmpty } from 'lodash'; +import { + isEmpty, + set, +} from 'lodash'; import { Accordion, @@ -45,7 +48,6 @@ import { handleKeyCommand, getPatronGroup, getTlrSettings, - isSubmittingButtonDisabled, resetFieldState, getFulfillmentTypeOptions, getDefaultRequestPreferences, @@ -91,7 +93,6 @@ class RequestForm extends React.Component { }), }).isRequired, setRequest: PropTypes.func, - pristine: PropTypes.bool, submitting: PropTypes.bool, patronGroups: PropTypes.arrayOf(PropTypes.object), selectedItem: PropTypes.object, @@ -101,7 +102,6 @@ class RequestForm extends React.Component { }; static defaultProps = { - pristine: true, submitting: false, }; @@ -130,6 +130,7 @@ class RequestForm extends React.Component { titleLevelRequestsFeatureEnabled, }; this.accordionStatusRef = React.createRef(); + this.editMediatedRequestData = {}; } componentDidMount() { @@ -162,7 +163,6 @@ class RequestForm extends React.Component { getRequestDataForEditing = (request = this.props.request) => { const { - form, onSetSelectedProxy, onSetSelectedInstance, onSetSelectedItem, @@ -171,13 +171,15 @@ class RequestForm extends React.Component { const isTlr = request.requestLevel === MEDIATED_REQUEST_LEVEL.TITLE; if (isTlr && request.instance?.hrid) { - form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.INSTANCE_HRID, request.instance.hrid); + this.setEditFormValue(MEDIATED_REQUEST_FORM_FIELD_NAMES.INSTANCE_HRID, request.instance.hrid); } else if (request.item?.barcode) { - form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.ITEM_BARCODE, request.item.barcode); + this.setEditFormValue(MEDIATED_REQUEST_FORM_FIELD_NAMES.ITEM_BARCODE, request.item.barcode); + this.setEditFormValue(MEDIATED_REQUEST_FORM_FIELD_NAMES.ITEM_ID, request.itemId); } - form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.REQUESTER_BARCODE, request.requester?.barcode); - form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.PATRON_COMMENTS, request.patronComments); + this.setEditFormValue(MEDIATED_REQUEST_FORM_FIELD_NAMES.REQUESTER_ID, request.requesterId); + this.setEditFormValue(MEDIATED_REQUEST_FORM_FIELD_NAMES.REQUESTER_BARCODE, request.requester?.barcode); + this.setEditFormValue(MEDIATED_REQUEST_FORM_FIELD_NAMES.PATRON_COMMENTS, request.patronComments); Promise.allSettled([ isTlr ? this.findInstance(request.instanceId, false) : this.findItem(RESOURCE_KEYS.ID, request.itemId, false, false), @@ -200,7 +202,7 @@ class RequestForm extends React.Component { } if (isProxyFunctionalityAvailable() && request.proxy) { - form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.PROXY_USER_ID, request.proxyUserId); + this.setEditFormValue(MEDIATED_REQUEST_FORM_FIELD_NAMES.PROXY_USER_ID, request.proxyUserId); onSetSelectedProxy(request.proxy); } @@ -696,11 +698,15 @@ class RequestForm extends React.Component { }); } + setEditFormValue = (fieldName, value) => { + const { form } = this.props; + + form.change(fieldName, value); + set(this.editMediatedRequestData, fieldName, value); + }; + setRequestPreferencesForEditing = (resourceId, requesterId, isTlr, request) => { - const { - form, - selectedUser, - } = this.props; + const { selectedUser } = this.props; if (resourceId && requesterId) { const resourceType = isTlr ? ID_TYPE_MAP.INSTANCE_ID : ID_TYPE_MAP.ITEM_ID; @@ -714,18 +720,18 @@ class RequestForm extends React.Component { const requestTypes = response[1]?.value; if (requestTypes?.[request.requestType]) { // when request type, fulfilment preference, pickup sp/delivery address were saved before - form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.REQUEST_TYPE, request.requestType); + this.setEditFormValue(MEDIATED_REQUEST_FORM_FIELD_NAMES.REQUEST_TYPE, request.requestType); if (request.fulfillmentPreference === FULFILMENT_TYPES.HOLD_SHELF) { - form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.FULFILLMENT_PREFERENCE, request.fulfillmentPreference); - form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.DELIVERY_ADDRESS_TYPE_ID, requestPreferences.defaultDeliveryAddressTypeId); + this.setEditFormValue(MEDIATED_REQUEST_FORM_FIELD_NAMES.FULFILLMENT_PREFERENCE, request.fulfillmentPreference); + this.setEditFormValue(MEDIATED_REQUEST_FORM_FIELD_NAMES.DELIVERY_ADDRESS_TYPE_ID, requestPreferences.defaultDeliveryAddressTypeId); this.setState({ hasDelivery: requestPreferences.hasDelivery }); // check if previously saved service point exists in list of available service points const selectedServicePoint = requestTypes[request.requestType]?.find(servicePoint => servicePoint.id === request.pickupServicePointId); if (selectedServicePoint) { - form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.PICKUP_SERVICE_POINT_ID, request.pickupServicePointId); + this.setEditFormValue(MEDIATED_REQUEST_FORM_FIELD_NAMES.PICKUP_SERVICE_POINT_ID, request.pickupServicePointId); } } else if (request.fulfillmentPreference === FULFILMENT_TYPES.DELIVERY && requestPreferences.hasDelivery) { this.setState({ @@ -733,18 +739,18 @@ class RequestForm extends React.Component { hasDelivery: true, }); - form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.FULFILLMENT_PREFERENCE, request.fulfillmentPreference); - form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.PICKUP_SERVICE_POINT_ID, requestPreferences.defaultServicePointId); + this.setEditFormValue(MEDIATED_REQUEST_FORM_FIELD_NAMES.FULFILLMENT_PREFERENCE, request.fulfillmentPreference); + this.setEditFormValue(MEDIATED_REQUEST_FORM_FIELD_NAMES.PICKUP_SERVICE_POINT_ID, requestPreferences.defaultServicePointId); // check if previously saved address exists in user's address list const selectedDeliveryAddress = selectedUser.personal.addresses?.find(address => request.deliveryAddressTypeId === address.addressTypeId); - form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.DELIVERY_ADDRESS_TYPE_ID, selectedDeliveryAddress?.addressTypeId || requestPreferences.defaultDeliveryAddressTypeId); + this.setEditFormValue(MEDIATED_REQUEST_FORM_FIELD_NAMES.DELIVERY_ADDRESS_TYPE_ID, selectedDeliveryAddress?.addressTypeId || requestPreferences.defaultDeliveryAddressTypeId); } } else { // when request type, fulfilment preference, pickup SP/delivery address were not saved before - form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.FULFILLMENT_PREFERENCE, requestPreferences.fulfillmentPreference); - form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.PICKUP_SERVICE_POINT_ID, requestPreferences.defaultServicePointId); - form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.DELIVERY_ADDRESS_TYPE_ID, requestPreferences.defaultDeliveryAddressTypeId); + this.setEditFormValue(MEDIATED_REQUEST_FORM_FIELD_NAMES.FULFILLMENT_PREFERENCE, requestPreferences.fulfillmentPreference); + this.setEditFormValue(MEDIATED_REQUEST_FORM_FIELD_NAMES.PICKUP_SERVICE_POINT_ID, requestPreferences.defaultServicePointId); + this.setEditFormValue(MEDIATED_REQUEST_FORM_FIELD_NAMES.DELIVERY_ADDRESS_TYPE_ID, requestPreferences.defaultDeliveryAddressTypeId); this.setState({ hasDelivery: requestPreferences.hasDelivery, isDeliverySelected: requestPreferences.isDeliverySelected, @@ -752,14 +758,24 @@ class RequestForm extends React.Component { } }) .catch(() => { - form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.REQUEST_TYPE, DEFAULT_REQUEST_TYPE_VALUE); - form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.FULFILLMENT_PREFERENCE, EMPTY_MEDIATED_REQUEST_FORM_VALUE); - form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.PICKUP_SERVICE_POINT_ID, EMPTY_MEDIATED_REQUEST_FORM_VALUE); - form.change(MEDIATED_REQUEST_FORM_FIELD_NAMES.DELIVERY_ADDRESS_TYPE_ID, EMPTY_MEDIATED_REQUEST_FORM_VALUE); - }); + this.setEditFormValue(MEDIATED_REQUEST_FORM_FIELD_NAMES.REQUEST_TYPE, DEFAULT_REQUEST_TYPE_VALUE); + this.setEditFormValue(MEDIATED_REQUEST_FORM_FIELD_NAMES.FULFILLMENT_PREFERENCE, EMPTY_MEDIATED_REQUEST_FORM_VALUE); + this.setEditFormValue(MEDIATED_REQUEST_FORM_FIELD_NAMES.PICKUP_SERVICE_POINT_ID, EMPTY_MEDIATED_REQUEST_FORM_VALUE); + this.setEditFormValue(MEDIATED_REQUEST_FORM_FIELD_NAMES.DELIVERY_ADDRESS_TYPE_ID, EMPTY_MEDIATED_REQUEST_FORM_VALUE); + }) + .then(this.resetEditMediatedRequestForm); + } else { + this.resetEditMediatedRequestForm(); } }; + /* resetting form values for edit mediated request page let us click "Cancel" button + or cross at the left top corner without having "Are you sure?" modal. + Form resetting happens only once and only after first loading of "Edit mediated request" page */ + resetEditMediatedRequestForm = () => { + this.props.form.reset(this.editMediatedRequestData); + }; + findRequestTypes = (resourceId, requesterId, resourceType) => { const { findResource, @@ -864,7 +880,6 @@ class RequestForm extends React.Component { selectedInstance, values, onCancel, - pristine, onSetSelectedItem, onSetSelectedInstance, onSetSelectedUser, @@ -875,7 +890,6 @@ class RequestForm extends React.Component { let addressDetail; const { createTitleLevelRequest } = values; const patronGroup = getPatronGroup(selectedUser, patronGroups); - const isSubmittingDisabled = isSubmittingButtonDisabled(pristine, submitting); const isTitleLevelRequest = isEditMode ? request?.requestLevel === MEDIATED_REQUEST_LEVEL.TITLE : createTitleLevelRequest; const isTlrCheckboxDisabled = !titleLevelRequestsFeatureEnabled || isItemOrInstanceLoading; const requestTypeOptions = getRequestTypesOptions(requestTypes); @@ -885,7 +899,7 @@ class RequestForm extends React.Component { deliveryLocations, deliveryLocationsDetail, } = getDeliveryInformation(selectedUser, addressTypes); - const isSaveAndCloseButtonDisabled = isSubmittingDisabled || !(isTitleLevelRequest ? selectedInstance?.id : selectedItem?.id) || !selectedUser?.id; + const isSaveAndCloseButtonDisabled = submitting || !(isTitleLevelRequest ? selectedInstance?.id : selectedItem?.id) || !selectedUser?.id; const isConfirmButtonDisabled = isSaveAndCloseButtonDisabled || !values.requestType || !(isDeliverySelected ? values.deliveryAddressTypeId : values.pickupServicePointId); const paneTitle = isEditMode ? : ; const isTlrCheckboxVisible = titleLevelRequestsFeatureEnabled && !isEditMode; @@ -901,7 +915,7 @@ class RequestForm extends React.Component { onSubmit={handleSubmit} onCancel={this.handleCancelAndClose} accordionStatusRef={this.accordionStatusRef} - isSubmittingDisabled={isSubmittingDisabled} + isSubmittingDisabled={submitting} > ({ })), handleKeyCommand: jest.fn(), getPatronGroup: jest.fn(), - isSubmittingButtonDisabled: jest.fn(), resetFieldState: jest.fn(), getFulfillmentTypeOptions: jest.fn(() => []), getDefaultRequestPreferences: jest.fn(), diff --git a/src/components/SendItemInTransit/SendItemInTransit.js b/src/components/SendItemInTransit/SendItemInTransit.js index e8bd719..0294448 100644 --- a/src/components/SendItemInTransit/SendItemInTransit.js +++ b/src/components/SendItemInTransit/SendItemInTransit.js @@ -30,8 +30,8 @@ import ContentToPrint from './components'; import css from './SendItemInTransit.css'; const SEND_ITEM_IN_TRANSIT_URL = 'requests-mediated/send-item-in-transit'; -const PRINT_BUTTON_SELECTOR = 'printButton'; const CONTENT_TO_PRINT_ID = 'contentToPrint'; +export const PRINT_BUTTON_SELECTOR = 'printButton'; const SendItemInTransit = () => { const contentToPrintRef = useRef(); diff --git a/src/components/SendItemInTransit/SendItemInTransit.test.js b/src/components/SendItemInTransit/SendItemInTransit.test.js index 0c8f02c..882c992 100644 --- a/src/components/SendItemInTransit/SendItemInTransit.test.js +++ b/src/components/SendItemInTransit/SendItemInTransit.test.js @@ -1,16 +1,26 @@ import { render, + screen, + fireEvent, } from '@folio/jest-config-stripes/testing-library/react'; -import SendItemInTransit from './SendItemInTransit'; +import SendItemInTransit, { + PRINT_BUTTON_SELECTOR, +} from './SendItemInTransit'; import ConfirmItem from '../ConfirmItem'; import ErrorModal from '../ErrorModal'; +import { handleConfirmItemSubmit } from '../../utils'; import { CONFIRM_ITEM_TYPES, getSendItemInTransitUrl, } from '../../constants'; +const testIds = { + confirmItemForm: 'confirmItemForm', + closeModalButton: 'closeModalButton', +}; + jest.mock('../../hooks', () => ({ useStaffSlipsTemplate: jest.fn(() => ({ staffSlips: [], @@ -18,9 +28,45 @@ jest.mock('../../hooks', () => ({ })); jest.mock('../../utils', () => ({ getStaffSlipsTemplateByType: jest.fn(() => ''), + handleConfirmItemSubmit: jest.fn((itemBarcode, confirmItemState, confirmItemProps) => { + confirmItemProps.onSuccess(); + }), +})); +jest.mock('../ConfirmItem', () => jest.fn(({ + onSubmit, +}) => { + return ; +})); +jest.mock('../ErrorModal', () => jest.fn(({ + onClose, +}) => { + return ( + + ); +})); +jest.mock('react-to-print', () => jest.fn(({ + content, + trigger, + onAfterPrint, +}) => { + onAfterPrint(); + content(); + + return ( +
+ {trigger()} +
+ ); })); -jest.mock('../ConfirmItem', () => jest.fn((props) => (
))); -jest.mock('../ErrorModal', () => jest.fn((props) => (
))); const messageIds = { paneTitle: 'ui-requests-mediated.sendItemInTransit.paneTitle', @@ -33,6 +79,10 @@ describe('SendItemInTransit', () => { render(); }); + afterEach(() => { + jest.clearAllMocks(); + }); + it('should render ConfirmItem with correct props', () => { expect(ConfirmItem).toHaveBeenCalledWith(expect.objectContaining({ paneTitle: messageIds.paneTitle, @@ -51,4 +101,35 @@ describe('SendItemInTransit', () => { onClose: expect.any(Function), }), {}); }); + + it('should handle data submitting', () => { + const confirmItemForm = screen.getByTestId(testIds.confirmItemForm); + + fireEvent.submit(confirmItemForm); + + expect(handleConfirmItemSubmit).toHaveBeenCalled(); + }); + + it('should render print button', () => { + const printButton = screen.getByText(PRINT_BUTTON_SELECTOR); + + expect(printButton).toBeInTheDocument(); + }); + + it('should close error modal', () => { + const confirmItemForm = screen.getByTestId(testIds.confirmItemForm); + + handleConfirmItemSubmit.mockImplementationOnce((itemBarcode, confirmItemState) => { + confirmItemState.setIsErrorModalOpen(true); + }); + fireEvent.submit(confirmItemForm); + + const closeModalButton = screen.getByTestId(testIds.closeModalButton); + + fireEvent.click(closeModalButton); + + expect(ErrorModal).toHaveBeenCalledWith(expect.objectContaining({ + open: false, + }), {}); + }); }); diff --git a/src/routes/MediatedRequestsActivitiesContainer.test.js b/src/routes/MediatedRequestsActivitiesContainer.test.js index eea5c67..37ba728 100644 --- a/src/routes/MediatedRequestsActivitiesContainer.test.js +++ b/src/routes/MediatedRequestsActivitiesContainer.test.js @@ -20,26 +20,32 @@ const testIds = { }; const mockFetchMore = jest.fn(); const mockFetchOffset = jest.fn(); +const mockUpdate = jest.fn(); jest.mock('@folio/stripes/smart-components', () => ({ ...jest.requireActual('@folio/stripes/smart-components'), StripesConnectedSource: jest.fn().mockImplementation(() => ({ fetchMore: mockFetchMore, fetchOffset: mockFetchOffset, + update: mockUpdate, })), })); -jest.mock('../components/MediatedRequestsActivities', () => jest.fn((props) => ( -
- -
-))); +jest.mock('../components/MediatedRequestsActivities', () => jest.fn((props) => { + props.queryGetter(); + + return ( +
+ +
+ ); +})); const logger = { log: jest.fn(), @@ -80,32 +86,108 @@ const props = { resources, mutator, settings, + children:
, }; describe('MediatedRequestsActivitiesContainer', () => { - beforeEach(() => { - render(); + describe('Initial render', () => { + beforeEach(() => { + render(); + }); + + it('should render mediated requests activities with correct props', () => { + expect(MediatedRequestsActivities).toHaveBeenCalledWith(expect.objectContaining({ + onNeedMoreData: expect.any(Function), + resources, + mutator, + settings, + }), {}); + }); + + it('should trigger onNeedMoreData', async () => { + await userEvent.click(screen.getByText('onNeedMoreData')); + + expect(mockFetchMore).toHaveBeenCalledWith(PAGE_AMOUNT); + }); }); - it('should render mediated requests activities with correct props', () => { - expect(MediatedRequestsActivities).toHaveBeenCalledWith(expect.objectContaining({ - onNeedMoreData: expect.any(Function), - resources, - mutator, - settings, - }), {}); + describe('Component updating', () => { + beforeEach(() => { + const { rerender } = render(); + const newProps = { + ...props, + location: { + state: { + search: 'test', + pathname: '', + }, + }, + }; + + rerender(); + }); + + it('should update source', () => { + expect(mockUpdate).toHaveBeenCalled(); + }); }); -}); - -describe('onNeedMoreData', () => { - beforeEach(() => { - render(); - }); - - it('should trigger onNeedMoreData', async () => { - await userEvent.click(screen.getByText('onNeedMoreData')); - expect(mockFetchMore).toHaveBeenCalledWith(PAGE_AMOUNT); + describe('querySetter', () => { + describe('When query data is provided', () => { + const queryData = { + nsValues: { + query: 'query*', + }, + state: { + sortChanged: true, + changeType: 'reset', + }, + }; + + beforeEach(() => { + MediatedRequestsActivities.mockImplementationOnce(({ querySetter }) => { + querySetter(queryData); + }); + + render(); + }); + + it('should trigger "resultOffset.replace"', () => { + expect(props.mutator.resultOffset.replace).toHaveBeenCalledWith(0); + }); + + it('should replace query params', () => { + expect(props.mutator.query.replace).toHaveBeenCalledWith(queryData.nsValues); + }); + + it('should redirect to new page', () => { + expect(props.history.push).toHaveBeenCalled(); + }); + }); + + describe('When query data is not provided', () => { + const queryData = { + nsValues: { + query: '', + }, + state: { + sortChanged: false, + changeType: '', + }, + }; + + beforeEach(() => { + MediatedRequestsActivities.mockImplementationOnce(({ querySetter }) => { + querySetter(queryData); + }); + + render(); + }); + + it('should update query params', () => { + expect(props.mutator.query.update).toHaveBeenCalledWith(queryData.nsValues); + }); + }); }); }); diff --git a/src/utils.js b/src/utils.js index 92ac118..b87118a 100644 --- a/src/utils.js +++ b/src/utils.js @@ -91,8 +91,6 @@ export const getPatronGroup = (patron, patronGroups) => { return patronGroups.find(group => group.id === id); }; -export const isSubmittingButtonDisabled = (pristine, submitting) => pristine || submitting; - const isYear = (value) => { const YEAR_REGEX = /^([1-9]\d{0,3})$/; @@ -323,6 +321,8 @@ export const getDeliveryAddressForCsvRecords = (address) => { return [addressLine1, city, region, postalCode, countryId].filter(Boolean).join(' '); }; +export const isProxyFunctionalityAvailable = () => IS_PROXY_AVAILABLE; + export const modifyRecordsToExport = (records) => { return records.map(record => { const { @@ -518,5 +518,3 @@ export const convertToSlipData = (source, intl, timeZone, locale) => { return slipData; }; - -export const isProxyFunctionalityAvailable = () => IS_PROXY_AVAILABLE; diff --git a/src/utils.test.js b/src/utils.test.js index 21d46ce..e5de6fc 100644 --- a/src/utils.test.js +++ b/src/utils.test.js @@ -26,7 +26,6 @@ import { memoizeValidation, getTlrSettings, getPatronGroup, - isSubmittingButtonDisabled, getFormattedYears, getInstanceQueryString, getFulfillmentTypeOptions, @@ -367,32 +366,6 @@ describe('utils', () => { }); }); - describe('isSubmittingButtonDisabled', () => { - describe('when pristine is true and submitting is false', () => { - it('should return true', () => { - expect(isSubmittingButtonDisabled(true, false)).toBe(true); - }); - }); - - describe('when pristine is false and submitting is true', () => { - it('should return true', () => { - expect(isSubmittingButtonDisabled(false, true)).toBe(true); - }); - }); - - describe('when pristine is true and submitting is true', () => { - it('should return true', () => { - expect(isSubmittingButtonDisabled(true, true)).toBe(true); - }); - }); - - describe('when pristine is false and submitting is false', () => { - it('should return true', () => { - expect(isSubmittingButtonDisabled(false, false)).toBe(false); - }); - }); - }); - describe('getFormattedYears', () => { describe('When publications are not passed', () => { it('should return empty string', () => {