Enzyme: .hasClass with several class names

Created on 11 Apr 2016  路  5Comments  路  Source: enzymejs/enzyme

How to check if an element has a list of classes ?
Example:
expect(ShowMoreLessButton.hasClass('btn', 'btn-sm')).to.equal(true);

Most helpful comment

expect(['btn', 'btn-sm'].every(c => ShowMoreLessButton.hasClass(c))).to.equal(true)?

All 5 comments

expect(['btn', 'btn-sm'].every(c => ShowMoreLessButton.hasClass(c))).to.equal(true)?

const wrapper = mount(
content={content}
/>
);
const post = wrapper.find('article');
expect(['top', 'active'].every(c => post.hasClass(c))).to.equal(true);

I've just tested here and you can do expect(ShowMoreLessButton.hasClass('btn btn-sm')).to.equal(true);

It should support querying for multiple classes now, so I'll close this.

if 3 dropdown select then button clicked

Was this page helpful?
0 / 5 - 0 ratings