Skip to content

Commit

Permalink
Prevent excess space when the program name is toggled off
Browse files Browse the repository at this point in the history
  • Loading branch information
crismali committed Jan 23, 2024
1 parent a27ef69 commit 73fc298
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const sizeForSubComponentKind = (
case 'RulesRightsRegulations':
return 'extraLarge'
case 'Title':
return 'large'
return shouldShowNext ? 'large' : undefined
case 'Intro':
return 'medium'
case 'SupplementalContent':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,35 @@ describe('EmailSubComponentSpacer', () => {
expect(size).toBeUndefined()
})

it('is large when the subcomponent is Title', () => {
const size = renderWithSubComponents({
currentSubComponent: 'Title',
nextSubComponent: 'ProgramName',
describe('Title', () => {
it('is large when the next subcomponent should be shown', () => {
const size = renderWithSubComponents({
currentSubComponent: 'Title',
nextSubComponent: 'ProgramName',
})
expect(size).toEqual(`${spacingCellSizes.large}px`)
})

it('is nothing when the next subcomponent should not be shown', () => {
const nextSubComponent = buildUniqueEmailSubComponent('Body', {
kind: 'ProgramName',
})
const { baseElement } = render(
<ShouldShowEmailPart initialData={{ [nextSubComponent.id]: false }}>
<EmailSubComponentSpacer
currentSubComponent={buildUniqueEmailSubComponent('Body', {
kind: 'Title',
})}
nextSubComponent={nextSubComponent}
/>
</ShouldShowEmailPart>,
{
wrapper: emailPartWrapper,
},
)
const spacer = baseElement.querySelector('td')
expect(spacer).toBeNull()
})
expect(size).toEqual(`${spacingCellSizes.large}px`)
})

it('is nothing when the subcomponent is ProgramName', () => {
Expand Down

0 comments on commit 73fc298

Please sign in to comment.