Skip to content

Commit

Permalink
✨ handle useLayoutEffect react hook
Browse files Browse the repository at this point in the history
  • Loading branch information
FBerthelot committed Apr 19, 2019
1 parent 72ed91d commit b6ffc7a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/component-test-utils-react/src/dispatcher/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ class Dispatcher {
...objectBuilder()
};
}

useLayoutEffect(...args) {
return this.useEffect(...args);
}
}

exports.createDispatcher = shallowedComponent => {
Expand Down
13 changes: 13 additions & 0 deletions packages/component-test-utils-react/src/dispatcher/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,17 @@ describe('dispatcher', () => {
expect(objectBuilder).toHaveBeenCalledTimes(2);
});
});

describe('useLayoutEffect', () => {
it('should call useEffect', () => {
dispatcher.useEffect = jest.fn(() => 4);

const args = [jest.fn(), [1, 4]];

const res = dispatcher.useLayoutEffect(...args);

expect(dispatcher.useEffect).toHaveBeenCalledWith(...args);
expect(res).toBe(4);
});
});
});

0 comments on commit b6ffc7a

Please sign in to comment.