Skip to content

Commit 05f1616

Browse files
committed
Add test for React class placeholders
1 parent 7d3bb6a commit 05f1616

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/components/PlaceholderWithoutTracking.spec.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* eslint require-jsdoc: 0 */
22
/* eslint max-len: 0 */
3+
/* eslint max-statements: 0 */
4+
/* eslint newline-after-var: 0 */
35
import React from 'react';
46
import ReactTestUtils from 'react-dom/test-utils';
57
import { configure, mount } from 'enzyme';
@@ -85,6 +87,25 @@ describe('PlaceholderWithoutTracking', function() {
8587
expectPlaceholders(component, 1, 'strong');
8688
});
8789

90+
it('renders the prop placeholder (React class) when it\'s not in the viewport', function() {
91+
const style = { marginTop: 100000 };
92+
class MyComponent extends React.Component {
93+
render() {
94+
return (
95+
<strong style={style}></strong>
96+
);
97+
}
98+
}
99+
const placeholder = (<MyComponent />);
100+
const component = renderPlaceholderWithoutTracking({
101+
placeholder,
102+
style,
103+
});
104+
105+
expectParagraphs(component, 0);
106+
expectPlaceholders(component, 1, 'strong');
107+
});
108+
88109
it('doesn\'t trigger onVisible when the image is not the viewport', function() {
89110
const onVisible = jest.fn();
90111
const component = renderPlaceholderWithoutTracking({

0 commit comments

Comments
 (0)