Skip to content
This repository was archived by the owner on Jun 10, 2020. It is now read-only.

Loading items on container height dynamically changed #192

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions __tests__/infinite_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,71 @@ describe("React Infinite's Infinite Scroll Capabilities", function() {
expect(infiniteSpy).not.toHaveBeenCalled();
});

it('triggers the onInfiniteLoad function when containerHeight changes', function() {
Copy link

@DevSide DevSide May 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you may provide the case where useWindowAsScrollContainer is true so when containerHeight changes, onInfiniteLoad is not called

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

var infiniteSpy = jasmine.createSpy('infiniteSpy');
var elementHeight = 200;

var rootNode = document.createElement('div');

ReactDOM.render(
<Infinite elementHeight={elementHeight}
containerHeight={400}
onInfiniteLoad={infiniteSpy}
infiniteLoadBeginEdgeOffset={100}
className={"correct-class-name"}>
{renderHelpers.divGenerator(2, elementHeight)}
</Infinite>,
rootNode
);

ReactDOM.render(
<Infinite elementHeight={elementHeight}
containerHeight={1000}
onInfiniteLoad={infiniteSpy}
infiniteLoadBeginEdgeOffset={100}
className={"correct-class-name"}>
{renderHelpers.divGenerator(2, elementHeight)}
</Infinite>,
rootNode
);

expect(infiniteSpy).toHaveBeenCalled();
});

it('does not trigger the onInfiniteLoad function when containerHeight changes and useWindowAsScrollContainer is true', function() {
var infiniteSpy = jasmine.createSpy('infiniteSpy');
var elementHeight = 200;
window.innerHeight = 400;

var rootNode = document.createElement('div');

ReactDOM.render(
<Infinite elementHeight={elementHeight}
containerHeight={400}
onInfiniteLoad={infiniteSpy}
infiniteLoadBeginEdgeOffset={100}
useWindowAsScrollContainer
className={"correct-class-name"}>
{renderHelpers.divGenerator(2, elementHeight)}
</Infinite>,
rootNode
);

ReactDOM.render(
<Infinite elementHeight={elementHeight}
containerHeight={1000}
onInfiniteLoad={infiniteSpy}
infiniteLoadBeginEdgeOffset={100}
useWindowAsScrollContainer
className={"correct-class-name"}>
{renderHelpers.divGenerator(2, elementHeight)}
</Infinite>,
rootNode
);

expect(infiniteSpy).not.toHaveBeenCalled();
});

it('triggers the onInfiniteLoad function when scrolling past infiniteLoadBeginEdgeOffset', function() {
var infiniteSpy = jasmine.createSpy('infiniteSpy');
var elementHeight = 200;
Expand Down
Loading