Skip to content

Feature/by asim/accordion#113

Open
asimbhdr96 wants to merge 9 commits intomasterfrom
feature/byAsim/Accordion
Open

Feature/by asim/accordion#113
asimbhdr96 wants to merge 9 commits intomasterfrom
feature/byAsim/Accordion

Conversation

@asimbhdr96
Copy link
Collaborator

import Accordion from './Accordion';
import AccordionDetail from './AccordionDetail';
import AccordionHeader from './AccordionHeader';

Copy link
Owner

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have done this

}

export const ControlledAccordion:React.FC = () => {
const [expanded, setExpanded] = React.useState<string | false >(false);
Copy link
Owner

Choose a reason for hiding this comment

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

bad logic here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

</Accordion>
</AccordionDetail>
</Accordion>
}
Copy link
Owner

Choose a reason for hiding this comment

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

add Nested According example

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added


it('should render items', () => {
const headerSec = 'HelloFromHeader'
const detailSec = 'HelloFromDetail'
Copy link
Owner

Choose a reason for hiding this comment

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

rename it for better understanding

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

renamed

</AccordionDetail>
</Accordion>)
const activeDiv = document.querySelector('.accordion-container.active')
expect(activeDiv).toHaveClass('accordion-container active')
Copy link
Owner

Choose a reason for hiding this comment

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

also testing close

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added

</AccordionDetail>
</Accordion>)
const headerEl = screen.queryByText(headerSec) as HTMLDivElement
fireEvent.click(headerEl)
Copy link
Owner

Choose a reason for hiding this comment

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

test before click

Copy link
Collaborator

Choose a reason for hiding this comment

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

Should be good. Accordion element is checked to see if it does not have the 'active' class before the click. Then, it is checked after the click to see if it has the 'active' class


expect(Object.values(accordionHeaderDiv)).toHaveLength(3)
})
// it('should open one at a time', () => {
Copy link
Owner

Choose a reason for hiding this comment

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

clear all the unuse code

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

cleared

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants