Как проверить на tabIndex в Чай / Фермент - PullRequest
0 голосов
/ 18 января 2019

Мы используем чай, мокко и фермент. Как я могу проверить tabIndex?

Этот тест работает для 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');
});

Но это не работает для 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
});

РЕДАКТИРОВАТЬ: это делает то, что мне нужно?

expect(wrapper.find({ 'data-test': 'button' }).prop('tabIndex')).to.equal(0);

Это работает, я не уверен на 100%, что я тестирую ...

...