diff --git a/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx b/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
index bda4036c9..f44d6e589 100644
--- a/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
+++ b/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx
@@ -31,6 +31,7 @@ import {
forwardRef,
memo,
PureComponent,
+ useState,
} from './_helpers/react-compat';
import {
describeIf,
@@ -1534,6 +1535,35 @@ describe('shallow', () => {
});
});
+ describeIf(is('>= 16.8'), 'hooks', () => {
+ it('handles useState', () => {
+ const ComponentUsingStateHook = () => {
+ const [count] = useState(0);
+ return
{count}
;
+ };
+
+ const wrapper = shallow();
+
+ expect(wrapper.find('div').length).to.equal(1);
+ expect(wrapper.find('div').text()).to.equal('0');
+ });
+
+ it('handles setState returned from useState', () => {
+ const ComponentUsingStateHook = () => {
+ const [count, setCount] = useState(0);
+ return setCount(count + 1)}>{count}
;
+ };
+
+ const wrapper = shallow();
+ const div = wrapper.find('div');
+ const setCount = div.prop('onClick');
+ setCount();
+ wrapper.update();
+
+ expect(wrapper.find('div').text()).to.equal('1');
+ });
+ });
+
describeWithDOM('find DOM elements by constructor', () => {
const { elements, all } = getData();