Skip to content

Commit

Permalink
fix(mentions): Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingze Xiao committed Jun 24, 2020
1 parent 2224ff1 commit e7d1063
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/components/ItemList/ItemList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ const ItemList = <T extends { id: string }>({
}

if (listEl.scrollTop > activeEl.offsetTop) {
listEl.scrollTop = activeEl.offsetTop;
listEl.scrollTop -= activeEl.offsetHeight;
} else if (listEl.scrollTop + listHeight < activeEl.offsetTop + activeEl.offsetHeight) {
listEl.scrollTop = activeEl.offsetTop + activeEl.offsetHeight - listHeight;
listEl.scrollTop += activeEl.offsetHeight;
}
},
[listRef],
Expand Down
6 changes: 3 additions & 3 deletions src/components/ItemList/__tests__/ItemList-test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { shallow, ShallowWrapper } from 'enzyme';
import { mount, ReactWrapper } from 'enzyme';
import ItemList, { Props } from '../ItemList';
import { Collaborator } from '../../../@types';

Expand All @@ -12,7 +12,7 @@ describe('components/ItemList/ItemList', () => {
onSelect: jest.fn(),
};

const getWrapper = (props = {}): ShallowWrapper => shallow(<ItemList {...defaults} {...props} />);
const getWrapper = (props = {}): ReactWrapper => mount(<ItemList {...defaults} {...props} />);

describe('render()', () => {
test('should render elements with correct props', () => {
Expand Down Expand Up @@ -41,7 +41,7 @@ describe('components/ItemList/ItemList', () => {
const firstChild = wrapper.find('[data-testid="ba-ItemList"]').childAt(0);

firstChild.simulate('click', mockEvent);
expect(defaults.onSelect).toBeCalledWith(0, mockEvent);
expect(defaults.onSelect).toBeCalledWith(0, expect.objectContaining(mockEvent));

firstChild.simulate('mousedown', mockEvent);
expect(mockEvent.preventDefault).toBeCalled();
Expand Down

0 comments on commit e7d1063

Please sign in to comment.