We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Here you have a working tests checking the scrollTop value when it calls doAutoScroll.
doAutoScroll
import { textarea } from 'pods/trainer/components/new-text.styles'; import React from 'react'; import { renderHook } from '@testing-library/react-hooks'; import { useAutoScroll } from './auto-scroll.hook'; describe('src/common/hooks/auto-scroll.hook specs', () => { it('should return initial values when it renders the hook', () => { // Arrange const textArea = { scrollHeight: 10, scrollTop: undefined, }; jest.spyOn(React, 'useRef').mockReturnValue({ current: textArea, }); // Act const { result } = renderHook(() => useAutoScroll()); // Assert expect(result.current.isAutoScrollEnabled).toBeTruthy(); expect(result.current.textAreaRef.current).not.toBeNull(); expect(result.current.textAreaRef.current.scrollHeight).toEqual(10); expect(result.current.textAreaRef.current.scrollTop).toBeUndefined(); }); it('should update scrollTop with height value when it call doAutoScroll', () => { // Arrange const textArea = { scrollHeight: 10, scrollTop: undefined, }; jest.spyOn(React, 'useRef').mockReturnValue({ current: textArea, }); // Act const { result } = renderHook(() => useAutoScroll()); result.current.doAutoScroll(); // Assert expect(result.current.textAreaRef.current.scrollTop).toEqual(10); }); });
isAutoScrollEnabled
scrollTop
The text was updated successfully, but these errors were encountered:
manudous
No branches or pull requests
Here you have a working tests checking the scrollTop value when it calls
doAutoScroll
.isAutoScrollEnabled
valuedoAutoScroll
and check it doesn't update thescrollTop
value.The text was updated successfully, but these errors were encountered: