davidtheclark / react-aria-menubutton

A fully accessible, easily themeable, React-powered menu button

Home Page:https://davidtheclark.github.io/react-aria-menubutton/demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Documentation for testing the components with frameworks like Jest/Enzyme

shah-vivek opened this issue · comments

I am working on a Project that consumes the components from react-aria-menubutton(RAM) package. I am facing a problem to unit test the parent component consuming the components from RAM package. Please find the details in following below.

I have a parent component that assembles the Menu, MenuItem, Button and Wrapper. Now I want to unit test the parent component by simulating the click events on Button, MenuItem etc to monitor the state changes of the parent component. I think simulation of events for Components in this package is not possible or I am doing it incorrectly. Any documentation on this would be really helpful.

I want something like following in my code

import {Button} from 'react-aria-menubutton'
import {shallow} from 'enzyme';
import ParentMenuButton from 'parent-menu-button';


describe('test RAM compoents', () => {
    test('should test state changes in the parent component',() =>{
       const wrapper = shallow(<ParentMenuButton />).find(Button).shallow();
      //Expect below code to trigger the click event for button
      wrapper.simulate('click',{
            preventDefault; () => {},
            stopePropogation: () => {}
      });
      
    } );
});

@shah-vivek This sounds like it's a question about Enzyme rather than this particular package. Might be suitable for StackOverflow.