Skip to content

Commit

Permalink
CU: Remove hideArrow code from AccordionCollapsible (#9802)
Browse files Browse the repository at this point in the history
Co-authored-by: Therese <[email protected]>
  • Loading branch information
juancstlm-a6 and TKDickson authored Oct 15, 2024
1 parent 189a894 commit 8dddb9a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 24 deletions.
10 changes: 2 additions & 8 deletions VAMobile/src/components/AccordionCollapsible.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ import Mock = jest.Mock

context('AccordionCollapsible', () => {
let onPressSpy: Mock
const initializeTestInstance = (hideArrow = false, expandedInitialValue = false) => {
const initializeTestInstance = (expandedInitialValue = false) => {
onPressSpy = jest.fn(() => {})
render(
<AccordionCollapsible
hideArrow={hideArrow}
header={<TextView>HEADER</TextView>}
expandedContent={<TextView>EXPANDED</TextView>}
collapsedContent={<TextView>COLLAPSED</TextView>}
Expand Down Expand Up @@ -43,13 +42,8 @@ context('AccordionCollapsible', () => {
expect(onPressSpy).toBeCalled()
})

it('when hideArrow set to true, cannot find tab to press', () => {
it('when expandedInitialValue is true it should show Expanded and not Collapsed content on load', () => {
initializeTestInstance(true)
expect(screen.queryByRole('tab')).toBeFalsy()
})

it('when expandedIntiailValue is true it should show Expanded and not Collapsed content on load', () => {
initializeTestInstance(false, true)
expect(screen.getByRole('tab', { name: 'HEADER' })).toBeTruthy()
expect(screen.queryByText('COLLAPSED')).toBeFalsy()
expect(screen.getByText('EXPANDED')).toBeTruthy()
Expand Down
19 changes: 3 additions & 16 deletions VAMobile/src/components/AccordionCollapsible.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ export type AccordionCollapsibleProps = {
a11yHint?: string
/** component to display on when the accordion is collapsed */
collapsedContent?: ReactNode
/** if true hides the accordion arrow and only displays header & collapsed content */
hideArrow?: boolean
/** custom on press call if more action is needed when expanding/collapsing the accordion */
customOnPress?: (expandedValue?: boolean) => void
/** sets the initial value of expanded if an accordion should already be expanded on render */
Expand All @@ -41,7 +39,6 @@ const AccordionCollapsible: FC<AccordionCollapsibleProps> = ({
header,
expandedContent,
collapsedContent,
hideArrow,
testID,
customOnPress,
expandedInitialValue,
Expand Down Expand Up @@ -78,11 +75,9 @@ const AccordionCollapsible: FC<AccordionCollapsibleProps> = ({
const data = (
<Box flexDirection="row">
<Box flex={1}>{header}</Box>
{!hideArrow && (
<Box alignItems="flex-end">
<Icon name={iconName} fill={theme.colors.icon.chevronCollapsible} width={30} height={30} />
</Box>
)}
<Box alignItems="flex-end">
<Icon name={iconName} fill={theme.colors.icon.chevronCollapsible} width={30} height={30} />
</Box>
</Box>
)

Expand All @@ -92,14 +87,6 @@ const AccordionCollapsible: FC<AccordionCollapsibleProps> = ({
}
: {}

if (hideArrow) {
return (
<Box {...labelProps} accessible={true}>
{data}
</Box>
)
}

return (
<Pressable {...pressableProps} {...labelProps} ref={headerRef}>
{data}
Expand Down

0 comments on commit 8dddb9a

Please sign in to comment.