Skip to content

Commit

Permalink
Add missing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Schmid authored and foaly-nr1 committed Jan 6, 2018
1 parent 9a96e42 commit 09cdcc7
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 4 deletions.
66 changes: 65 additions & 1 deletion packages/enzyme-test-suite/test/ReactWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@ describeWithDOM('mount', () => {

describeIf(!REACT013, 'stateless components', () => {
it('should match composite components', () => {
const Foo = () => <div />;
function Foo() {
return <div />;
}
const wrapper = mount((
<div>
<Foo />
Expand All @@ -353,6 +355,45 @@ describeWithDOM('mount', () => {
const b = <Foo />;
expect(wrapper.contains(b)).to.equal(true);
});

it('should match composite components if rendered by function', () => {
function Foo() {
return <div />;
}
const renderStatelessComponent = () => <Foo />;
const wrapper = mount((
<div>
{renderStatelessComponent()}
</div>
));
const b = <Foo />;
expect(wrapper.contains(b)).to.equal(true);
});

it('should match composite components based on component display name', () => {
function Foo() {
return <div />;
}
const wrapper = mount((
<div>
<Foo />
</div>
));
expect(wrapper.contains('Foo')).to.equal(true);
});

it('should match composite components based on component display name if rendered by function', () => {
function Foo() {
return <div />;
}
const renderStatelessComponent = () => <Foo />;
const wrapper = mount((
<div>
{renderStatelessComponent()}
</div>
));
expect(wrapper.contains('Foo')).to.equal(true);
});
});
});

Expand Down Expand Up @@ -483,6 +524,29 @@ describeWithDOM('mount', () => {
expect(wrapper.find('Foo').type()).to.equal(Foo);
});

describeIf(!REACT013, 'stateless components', () => {
it('should find a stateless component based on a component displayName', () => {
const Foo = () => <div />;
const wrapper = mount((
<div>
<Foo className="foo" />
</div>
));
expect(wrapper.find('Foo').type()).to.equal(Foo);
});

it('should find a stateless component based on a component displayName if rendered by function', () => {
const Foo = () => <div />;
const renderStatelessComponent = () => <Foo className="foo" />;
const wrapper = mount((
<div>
{renderStatelessComponent()}
</div>
));
expect(wrapper.find('Foo').type()).to.equal(Foo);
});
});

it('should find component based on a react prop', () => {
const wrapper = mount((
<div>
Expand Down
45 changes: 42 additions & 3 deletions packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,9 @@ describe('shallow', () => {

describeIf(!REACT013, 'stateless function components', () => {
it('should match composite components', () => {
const Foo = () => (
<div />
);
function Foo() {
return <div />;
}

const wrapper = shallow((
<div>
Expand All @@ -308,6 +308,45 @@ describe('shallow', () => {
const b = <Foo />;
expect(wrapper.contains(b)).to.equal(true);
});

it('should match composite components if rendered by function', () => {
function Foo() {
return <div />;
}
const renderStatelessComponent = () => <Foo />;
const wrapper = shallow((
<div>
{renderStatelessComponent()}
</div>
));
const b = <Foo />;
expect(wrapper.contains(b)).to.equal(true);
});

it('should match composite components based on component display name', () => {
function Foo() {
return <div />;
}
const wrapper = shallow((
<div>
<Foo />
</div>
));
expect(wrapper.contains('Foo')).to.equal(true);
});

it('should match composite components based on component display name if rendered by function', () => {
function Foo() {
return <div />;
}
const renderStatelessComponent = () => <Foo />;
const wrapper = shallow((
<div>
{renderStatelessComponent()}
</div>
));
expect(wrapper.contains('Foo')).to.equal(true);
});
});
});

Expand Down

0 comments on commit 09cdcc7

Please sign in to comment.