diff --git a/docs/api/ReactWrapper/isEmptyRender.md b/docs/api/ReactWrapper/isEmptyRender.md new file mode 100644 index 000000000..c9941d5b4 --- /dev/null +++ b/docs/api/ReactWrapper/isEmptyRender.md @@ -0,0 +1,18 @@ +# `.isEmptyRender() => Boolean` + +Returns whether or not the current component returns a falsy value: `false`, `null`, `undefined`. + +#### Returns + +`Boolean`: whether the return is falsy + +#### Example + +```jsx +function Foo() { + return null; +} + +const wrapper = mount(); +expect(wrapper.isEmptyRender()).to.be(true); +``` diff --git a/docs/api/ShallowWrapper/isEmptyRender.md b/docs/api/ShallowWrapper/isEmptyRender.md new file mode 100644 index 000000000..c4e336823 --- /dev/null +++ b/docs/api/ShallowWrapper/isEmptyRender.md @@ -0,0 +1,18 @@ +# `.isEmptyRender() => Boolean` + +Returns whether or not the current component returns a falsy value: `false`, `null`, `undefined`. + +#### Returns + +`Boolean`: whether the return is falsy + +#### Example + +```jsx +function Foo() { + return null; +} + +const wrapper = shallow(); +expect(wrapper.isEmptyRender()).to.be(true); +``` diff --git a/docs/api/mount.md b/docs/api/mount.md index 74b52fa50..1d8f3789d 100644 --- a/docs/api/mount.md +++ b/docs/api/mount.md @@ -95,6 +95,9 @@ Returns whether or not the current node exists. #### [`.isEmpty() => Boolean`](ReactWrapper/isEmpty.md) *Deprecated*: Use [.exists()](ReactWrapper/exists.md) instead. +#### [`.isEmptyRender() => Boolean`](ReactWrapper/isEmptyRender.md) +Returns whether or not the current component returns a falsy value. + #### [`.not(selector) => ReactWrapper`](ReactWrapper/not.md) Remove nodes in the current wrapper that match the provided selector. (inverse of `.filter()`) diff --git a/docs/api/shallow.md b/docs/api/shallow.md index bab067bc1..95b72eb36 100644 --- a/docs/api/shallow.md +++ b/docs/api/shallow.md @@ -100,6 +100,9 @@ Returns whether or not the current node exists. #### [`.isEmpty() => Boolean`](ShallowWrapper/isEmpty.md) *Deprecated*: Use [.exists()](ShallowWrapper/exists.md) instead. +#### [`.isEmptyRender() => Boolean`](ShallowWrapper/isEmptyRender.md) +Returns whether or not the current component returns a falsy value. + #### [`.not(selector) => ShallowWrapper`](ShallowWrapper/not.md) Remove nodes in the current wrapper that match the provided selector. (inverse of `.filter()`) diff --git a/test/ShallowTraversal-spec.jsx b/test/ShallowTraversal-spec.jsx index 62a7f714f..a6398e283 100644 --- a/test/ShallowTraversal-spec.jsx +++ b/test/ShallowTraversal-spec.jsx @@ -249,7 +249,7 @@ describe('ShallowTraversal', () => { ); - it('should return an empty array for falsey test', () => { + it('should return an empty array for falsy test', () => { expect(treeFilter(tree, () => false).length).to.equal(0); });