Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure resolveBEMNode preserves key prop #2

Closed
jednano opened this issue Oct 5, 2017 · 0 comments · Fixed by #16
Closed

Ensure resolveBEMNode preserves key prop #2

jednano opened this issue Oct 5, 2017 · 0 comments · Fixed by #16

Comments

@jednano
Copy link
Owner

jednano commented Oct 5, 2017

Had issues on a different project, so I'm not sure if this is an issue or not, but write a test anyway to be sure.

Something to this effect:

describe('resolveBEMNode', () => {
    it('preserves a key prop', () => {
        expect(
            resolveBEMNode(<div key="foo" />).key
        ).toEqual('foo');
    });

    it('transfers `key` property if present', () => {
        const renderer = createRenderer();
        const Component = () => resolveBEMNode(<div key="foo" block="bar" />);

        renderer.render(<Component />);
        const component = renderer.getRenderOutput();

        expect(component.key).toBe('foo');
    });

    it('does not add superfluous `key` property if not present', () => {
        const renderer = createRenderer();
        const Component = () => resolveBEMNode(<div block="bar" />);

        renderer.render(<Component />);
        const component = renderer.getRenderOutput();

        expect(component.key).toBe(null);
    });
});

Note: use shallow rendering instead.

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

Successfully merging a pull request may close this issue.

1 participant