Skip to content

Can't use string argument on 'with event' #67

@salomvary

Description

@salomvary

I was trying to use the shallow renderer to invoke a custom event handler with a string argument, eg. aliensLanded('thousand'). Tried this:

        it('calls events with string event parameter', () => {
            renderer.render(<ClickableComponent />);

            expect(renderer, 'with event', 'aliensLanded', 'thousand', 'to have rendered',
                <div>
                    <span className="main-click">Main clicked 1000</span>
                </div>);
        });

which did not work:

     UnexpectedError: 
Unknown assertion 'thousand', did you mean: 'on'

I understand telling the argument from the next assertion can be tricky if it's a string and the documentation clearly states that the argument has to be an object but custom "events" with non-object arguments are a real thing in my experience.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions