Skip to content

Commit

Permalink
fix(all): fixes tests import
Browse files Browse the repository at this point in the history
  • Loading branch information
Artemiy Vereshchinskiy committed Sep 29, 2020
1 parent cf8f5c3 commit 7be9dd0
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/__tests__/test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { shallow, ShallowWrapper } from 'enzyme';
import { MorefinityListLoader, MorefinityContainer, IMorefinityProps } from '../index';
import { MorefinityListLoader, Morefinity, IMorefinityProps } from '../index';
import { useState } from 'react';

const mockedItemHeight = 30;
Expand Down Expand Up @@ -36,8 +36,8 @@ const fetchItems = async (
});
};

describe('<MorefinityContainer />', () => {
const MorefinityContainerTest = () => {
describe('<Morefinity />', () => {
const MorefinityTest = () => {
const [items, setItems] = useState<{ id: number; text: string }[]>([
{
id: 0,
Expand All @@ -53,18 +53,18 @@ describe('<MorefinityContainer />', () => {
};
return (
<div className="App" style={{ height: '290px' }}>
<MorefinityContainer
<Morefinity
notAllLoaded={true}
isLoading={isLoading}
scrollOffset={100}
onScrollEnd={onScrollEnd}
>
{items.map(itemRenderer)}
</MorefinityContainer>
</Morefinity>
</div>
);
};
const container = shallow(<MorefinityContainerTest />);
const container = shallow(<MorefinityTest />);

let wrapper: ShallowWrapper;
const useEffect = jest.spyOn(React, 'useEffect');
Expand All @@ -84,21 +84,21 @@ describe('<MorefinityContainer />', () => {
};

test('should pass scrollOffset prop', () => {
expect(container.find(MorefinityContainer).props().scrollOffset).toBe(100);
expect(container.find(Morefinity).props().scrollOffset).toBe(100);
});

test('should request items with start offset and limit from props', () => {
mockUseEffect();
wrapper = shallow(<MorefinityContainer {...props} />);
wrapper = shallow(<Morefinity {...props} />);
expect(props.onScrollEnd).toBeCalledTimes(0);
});

test('container height should be equal to passed property', () => {
wrapper = shallow(<MorefinityContainer {...props} />);
wrapper = shallow(<Morefinity {...props} />);
expect(wrapper.find('div').props().height).toBe(props.height);
});

test('should render <MorefinityContainer />', () => {
test('should render <Morefinity />', () => {
expect(wrapper.length).toBe(1);
});

Expand Down

0 comments on commit 7be9dd0

Please sign in to comment.