Skip to content

Commit

Permalink
added 2 more tests for hasClass on composite components
Browse files Browse the repository at this point in the history
- passing test for composite component that renders composite component which itself renders a dom element
- failing test for composite component that renders null
  • Loading branch information
nfcampos committed Nov 13, 2016
1 parent 3157e81 commit 48b41d7
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/ReactWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2105,6 +2105,42 @@ describeWithDOM('mount', () => {
expect(wrapper.hasClass('doesnt-exist')).to.equal(false);
});
});

context('When using nested composite components', () => {
it('should return whether or not node has a certain class', () => {
class Foo extends React.Component {
render() {
return (<div className="foo bar baz some-long-string FoOo" />);
}
}
class Bar extends React.Component {
render() {
return <Foo />;
}
}
const wrapper = mount(<Bar />);

expect(wrapper.hasClass('foo')).to.equal(true);
expect(wrapper.hasClass('bar')).to.equal(true);
expect(wrapper.hasClass('baz')).to.equal(true);
expect(wrapper.hasClass('some-long-string')).to.equal(true);
expect(wrapper.hasClass('FoOo')).to.equal(true);
expect(wrapper.hasClass('doesnt-exist')).to.equal(false);
});
});

context('When using a Composite component that renders null', () => {
it('should return whether or not node has a certain class', () => {
class Foo extends React.Component {
render() {
return null;
}
}
const wrapper = mount(<Foo />);

expect(wrapper.hasClass('foo')).to.equal(false);
});
});
});

describe('.forEach(fn)', () => {
Expand Down

0 comments on commit 48b41d7

Please sign in to comment.