Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,44 @@ describe('LocationCollectionItem', () => {
expect(sunHours).not.to.exist();
});
});

context('when handleSelect callback is not provided', () => {
it('renders the component without the button', () => {
const onClick = sinon.stub();
const { container } = render(
<LocationCollectionItem
name=""
streetAddress=""
formattedCityStateZip=""
handleSelect={onClick}
weekdayHours=""
saturdayHours=""
selectId={0}
sundayHours=""
/>,
);

expect(container.textContent).to.contain('in_person_proofing.body.location.location_button');
});
});

context('when handleSelect callback is provided', () => {
it('renders the component with the button', () => {
const { container } = render(
<LocationCollectionItem
name=""
streetAddress=""
formattedCityStateZip=""
weekdayHours=""
saturdayHours=""
selectId={0}
sundayHours=""
/>,
);

expect(container.textContent).to.not.contain(
'in_person_proofing.body.location.location_button',
);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useI18n } from '@18f/identity-react-i18n';
interface LocationCollectionItemProps {
distance?: string;
formattedCityStateZip: string;
handleSelect: (event: React.MouseEvent, selection: number) => void;
handleSelect?: (event: React.MouseEvent, selection: number) => void;
name?: string;
saturdayHours: string;
selectId: number;
Expand Down Expand Up @@ -60,24 +60,28 @@ function LocationCollectionItem({
{`${t('in_person_proofing.body.location.retail_hours_sun')} ${sundayHours}`}
</div>
)}
<SpinnerButton
className="tablet:display-none margin-top-2 width-full"
onClick={(event) => handleSelect(event, selectId)}
type="submit"
>
{t('in_person_proofing.body.location.location_button')}
</SpinnerButton>
{handleSelect && (
<SpinnerButton
className="tablet:display-none margin-top-2 width-full"
onClick={(event) => handleSelect(event, selectId)}
type="submit"
>
{t('in_person_proofing.body.location.location_button')}
</SpinnerButton>
)}
</div>
<div className="grid-col-auto">
<SpinnerButton
className="display-none tablet:display-inline-block"
onClick={(event) => {
handleSelect(event, selectId);
}}
type="submit"
>
{t('in_person_proofing.body.location.location_button')}
</SpinnerButton>
{handleSelect && (
<SpinnerButton
className="display-none tablet:display-inline-block"
onClick={(event) => {
handleSelect(event, selectId);
}}
type="submit"
>
{t('in_person_proofing.body.location.location_button')}
</SpinnerButton>
)}
</div>
</div>
</div>
Expand Down