Skip to content

Commit

Permalink
fix(): beefed scrollbars branches coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Yair Even Or authored and Yair Even Or committed Nov 8, 2021
1 parent 7dc85e9 commit 6144dd1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ describe('<HorizontalScrollbar/>', () => {
rewire.__ResetDependency__('useRef');
rewire.__ResetDependency__('useContext');
});

it('handleOnClick() on thumb', () => {
const container = {current: {style: {}, scrollLeft: 0, scrollHeight: 200}};
const ref = {current: {contains: () => true, getBoundingClientRect: () => ({left: 0, width: 100})}};
rewire.__Rewire__('useRef', () => ref);
rewire.__Rewire__('useContext', () => ({container}));
const wrapper = shallow(<HorizontalScrollbar/>);

wrapper.find('.scrollbar-track').prop('onClick')({clientX: 50, stopPropagation: noop});
expect(container.current.scrollLeft).toEqual(0);

rewire.__ResetDependency__('useRef');
rewire.__ResetDependency__('useContext');
});
});

describe('Operations', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ describe('<VerticalScrollbar/>', () => {
rewire.__ResetDependency__('useRef');
rewire.__ResetDependency__('useContext');
});

it('handleOnClick() on thumb', () => {
const container = {current: {style: {}, scrollTop: 0, scrollHeight: 200}};
const ref = {current: {contains: () => true, getBoundingClientRect: () => ({top: 0, height: 100})}};
rewire.__Rewire__('useRef', () => ref);
rewire.__Rewire__('useContext', () => ({container}));
const wrapper = shallow(<VerticalScrollbar/>);

wrapper.find('.scrollbar-track').prop('onClick')({clientY: 50, stopPropagation: noop});
expect(container.current.scrollTop).toEqual(0);

rewire.__ResetDependency__('useRef');
rewire.__ResetDependency__('useContext');
});
});

describe('Operations', () => {
Expand Down

0 comments on commit 6144dd1

Please sign in to comment.