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 @@ -18,4 +18,18 @@ describe('PersonalInfoSummary', () => {

expect(getByText('October 6, 1938')).to.exist();
});

it('renders address', () => {
const { getByText, rerender } = render(<PersonalInfoSummary pii={DEFAULT_PII} />);

let address = getByText('1 FAKE RDGREAT FALLS, MT 59010');

expect([...address.childNodes].filter((node) => node.nodeName === 'BR')).to.have.lengthOf(1);

rerender(<PersonalInfoSummary pii={{ ...DEFAULT_PII, address2: 'PO BOX 1' }} />);

address = getByText('1 FAKE RDPO BOX 1GREAT FALLS, MT 59010');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's super weird to see the <br /> get hidden so the lines run together :/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this was a bit clumsy for me to put together, especially since I didn't realize we previously had an extra space in there as well. After removing that, it makes a bit more sense that the text content is the individual text nodes, joined together with no joiner.

There are some extra options for matching text (getByText((text) => ...), getByText('text', { normalizer: ... })), which could maybe be helpful for this. Or querying the individual slices of text and asserting against its sibling content (e.g. getByText('1 FAKE RD').nextElementSibling.nodeName === 'BR')).


expect([...address.childNodes].filter((node) => node.nodeName === 'BR')).to.have.lengthOf(2);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@ function PersonalInfoSummary({ pii }: PersonalInfoSummaryProps) {
</div>
<div className="margin-top-4 h6">{t('idv.review.mailing_address')}</div>
<div className="h4 text-bold ico-absolute ico-absolute-success">
{address1} <br />
{address2 || ''}
{address1}
<br />
{address2 && (
<>
{address2}
<br />
</>
)}
{city && state ? `${city}, ${state} ${zipcode}` : ''}
</div>
{dob && (
Expand Down