Skip to content

Commit

Permalink
[Tests] useEffect: add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
kii-dot authored and ljharb committed Mar 3, 2019
1 parent 081554e commit 01d2fda
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/enzyme-test-suite/test/shared/hooks/useEffect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,26 @@ export default function describeUseEffect({
});
});

it('will receive Props', () => {
function Foo(props) {
const [fooVal, setFooVal] = useState('');
const { initialFooVal } = props;
useEffect(() => {
setFooVal(initialFooVal);
}, [initialFooVal]);

return (
<div>
<p>{fooVal}</p>
</div>
);
}

const wrapper = Wrap(<Foo />);
wrapper.setProps({ initialFooVal: 'hey' });
expect(wrapper.find('p').text()).to.equal('hey');
});

describe('on componentDidUpdate & componentDidMount', () => {
const expectedCountString = x => `You clicked ${x} times`;

Expand Down

0 comments on commit 01d2fda

Please sign in to comment.