We're using Chai, Mocha and Enzyme. How can I test tabIndex
?
This test works for className
:
it('Renders a div with the default className of btn', () => {
let wrapper = shallow(
<Button className='btn' />,
);
expect(wrapper.find({ 'data-test': 'button' })).to.have.className('btn');
});
But this doesn't work for tabIndex
:
it.only('Renders with the appropriate tabIndex', () => {
let wrapper = shallow(
<Button tabIndex={0} />,
);
expect(wrapper.find({ 'data-test': 'button' })).to.have.tabIndex('0');
// undefined is not a constructor
});
EDIT: does this do what I need?
expect(wrapper.find({ 'data-test': 'button' }).prop('tabIndex')).to.equal(0);
It works, I'm not not 100% sure what I'm testing...