Skip to content

Commit

Permalink
Cleanup and more tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
randimays committed Jan 31, 2025
1 parent 33dcee2 commit 8e146d9
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ const MobileMapSearchResult = ({ mobileMapPinSelected, query }) => {

return (
<>
{!mobileMapPinSelected && (
{!mobileMapPinSelected ? (
<p className="vads-u-margin-y--3">
Select a number to show information about that location.
</p>
)}
{mobileMapPinSelected && (
) : (
<div className="mobile-search-result">
{ResultMapper(mobileMapPinSelected, query, 0, headerRef)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const SearchControls = props => {
clearSearchText,
currentQuery,
geolocateUser,
isMobile,
mobileMapUpdateEnabled,
onChange,
onSubmit,
selectMobileMapPin,
Expand Down Expand Up @@ -122,7 +124,10 @@ const SearchControls = props => {
'fl-current-zoom-depth': zoomLevel,
});

selectMobileMapPin(null);
if (isMobile && mobileMapUpdateEnabled) {
selectMobileMapPin(null);
}

onSubmit();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,7 @@ const Covid19Result = ({ location, index, query, headerRef = null }) => {
);

return (
<div
data-testid="covid-19-result"
className="facility-result"
id={location.id}
key={location.id}
>
<div className="facility-result" id={location.id} key={location.id}>
<>
<LocationMarker markerText={location.markerText} />
{isVADomain(website) ? (
Expand Down Expand Up @@ -125,7 +120,6 @@ Covid19Result.propTypes = {
PropTypes.shape({ current: PropTypes.object }),
]),
index: PropTypes.number,
isMobileCard: PropTypes.bool,
location: PropTypes.object,
query: PropTypes.object,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,15 +445,17 @@ const FacilitiesMap = props => {
/>
)}
<SearchControls
geolocateUser={props.geolocateUser}
clearGeocodeError={props.clearGeocodeError}
clearSearchText={props.clearSearchText}
currentQuery={currentQuery}
geolocateUser={props.geolocateUser}
isMobile={isMobile}
mobileMapUpdateEnabled={mobileMapUpdateEnabled}
onChange={props.updateSearchQuery}
onSubmit={handleSearch}
selectMobileMapPin={props.selectMobileMapPin}
suppressPPMS={props.suppressPPMS}
suppressPharmacies={props.suppressPharmacies}
clearSearchText={props.clearSearchText}
/>
{(isEmergencyCareType || isCppEmergencyCareTypes) && (
<VaAlert
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { expect } from 'chai';
import { isHealthAndHealthConnect } from '../../utils/phoneNumbers';

describe('phone number utils', () => {
describe('isHealthAndHealthConnect', () => {
it('should return true for VA health if the health connect number exists', () => {
expect(
isHealthAndHealthConnect(
{
attributes: {
phone: {
healthConnect: '123-456-7890',
},
},
},
{
facilityType: 'health',
},
),
).to.be.true;
});

it('should return false for VA health if the health connect number does not exist', () => {
expect(
isHealthAndHealthConnect(
{
attributes: {
phone: {
fax: '123-456-7890',
},
},
},
{
facilityType: 'health',
},
),
).to.be.false;
});

it('should return false for VA health if the health connect number is empty', () => {
expect(
isHealthAndHealthConnect(
{
attributes: {
phone: {
healthConnect: '',
},
},
},
{
facilityType: 'health',
},
),
).to.be.false;
});

it('should return false for Vet Centers', () => {
expect(
isHealthAndHealthConnect(
{
attributes: {
phone: {
healthConnect: '123-456-7890',
},
},
},
{
facilityType: 'vet_center',
},
),
).to.be.false;
});
});
});
12 changes: 3 additions & 9 deletions src/applications/facility-locator/utils/phoneNumbers.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,8 @@ export const parsePhoneNumber = phone => {
};

export const isHealthAndHealthConnect = (apiResult, searchQuery) => {
let final = false;

if (
return !!(
searchQuery?.facilityType === 'health' &&
apiResult?.attributes?.phone?.healthConnect !== null
) {
final = true;
}

return final;
apiResult?.attributes?.phone?.healthConnect
);
};

0 comments on commit 8e146d9

Please sign in to comment.