-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(lazy-load): lazyLoadOffset option does not work
- Loading branch information
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React from 'react'; | ||
import Screenshot from 'lib/static/components/state/screenshot'; | ||
import {mkConnectedComponent} from '../utils'; | ||
|
||
describe('Screenshot component', () => { | ||
const getLazyLoadComponent_ = ({lazyLoadOffset = 1} = {}) => { | ||
const screenshotComponent = mkConnectedComponent( | ||
<Screenshot image={{path: ''}} />, | ||
{initialState: {view: {lazyLoadOffset}}} | ||
); | ||
|
||
return screenshotComponent.find('LazyLoad'); | ||
}; | ||
|
||
describe('LazyLoad component', () => { | ||
it('should set "debounce" option', () => { | ||
const lazyLoadComponent = getLazyLoadComponent_(); | ||
|
||
assert.equal(lazyLoadComponent.props().debounce, 50); | ||
}); | ||
|
||
it('should set "once" option', () => { | ||
const lazyLoadComponent = getLazyLoadComponent_(); | ||
|
||
assert.isTrue(lazyLoadComponent.props().once); | ||
}); | ||
|
||
it('should pass offset from store to LazyLoad component', () => { | ||
const lazyLoadComponent = getLazyLoadComponent_({lazyLoadOffset: 333}); | ||
|
||
assert.equal(lazyLoadComponent.props().offset, 333); | ||
}); | ||
|
||
it('should not set placeholder by default', () => { | ||
const lazyLoadComponent = getLazyLoadComponent_(); | ||
|
||
assert.lengthOf(lazyLoadComponent.find('Placeholder'), 0); | ||
}); | ||
|
||
it('should set placeholder to LazyLoad component if passed image has size', () => { | ||
const screenshotComponent = mkConnectedComponent( | ||
<Screenshot image={{path: '', size: {}}} />, | ||
{initialState: {view: {lazyLoadOffset: 1}}} | ||
); | ||
|
||
assert.lengthOf(screenshotComponent.find('Placeholder'), 1); | ||
}); | ||
}); | ||
}); |