Reputation: 1197
I want to check whether an element is an a or a div, how do I accomplish this?
this code is not working:
it('has no link if required', () => {
const wrapper = shallow(<AssetOverlay asset={ assetsData[0] } shouldBeLinked />);
expect(wrapper.find('.overlay-asset-link')).to.be.a('a');
const wrapper1 = shallow(<AssetOverlay asset={ assetsData[0] } shouldBeLinked="false" />);
//expect(wrapper1.find('.overlay-asset-link')).to.be.a('div');
});
Upvotes: 2
Views: 2340
Reputation: 4802
Well thats because chais type checking checks for javascript types, not for HTML-Tags.
In case wrapper.find()
returns a normal HTML-Element, you could achieve what you want to test with:
expect(wrapper.find('.overlay-asset-link').tagName).to.equal('A');
Note: The tagname-property is always uppercase.
Upvotes: 2