Skip to content

Commit

Permalink
Fix hook outside of component test (#2359)
Browse files Browse the repository at this point in the history
* fix test

* add return value
  • Loading branch information
JoviDeCroock authored Feb 19, 2020
1 parent cbe0782 commit f20bf41
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions debug/test/browser/debug-hooks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,15 @@ describe('debug with hooks', () => {
expect(fn).to.throw(/Hook can only be invoked from render/);
});

// TODO: Fix this test. It only passed before because render was never called.
// Once render is called, currentComponent is set and never unset so calls to
// hooks outside of components would still work.
it.skip('should throw an error when invoked outside of a component', () => {
function Foo(props) {
it('should throw an error when invoked outside of a component', () => {
function foo() {
useEffect(() => {}); // Pretend to use a hook
return props.children;
return <p>test</p>;
}

const fn = () =>
act(() => {
render(<Foo>Hello!</Foo>, scratch);
useState();
render(foo(), scratch);
});
expect(fn).to.throw(/Hook can only be invoked from render/);
});
Expand Down

0 comments on commit f20bf41

Please sign in to comment.