Skip to content

Commit 83818c1

Browse files
committed
Add tests for background reset after image is loaded
1 parent af38d08 commit 83818c1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/components/LazyLoadImage.spec.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ configure({ adapter: new Adapter() });
1212

1313
const {
1414
findRenderedComponentWithType,
15+
findRenderedDOMComponentWithClass,
1516
findRenderedDOMComponentWithTag,
1617
scryRenderedDOMComponentsWithClass,
1718
scryRenderedDOMComponentsWithTag,
@@ -83,6 +84,21 @@ describe('LazyLoadImage', function() {
8384
expect(loadedWrapper.length).toEqual(1);
8485
});
8586

87+
it('resets the background-image and background-size when img triggers onLoad', function() {
88+
const lazyLoadImage = mount(
89+
<LazyLoadImage effect="blur" />
90+
);
91+
92+
const img = findRenderedDOMComponentWithTag(lazyLoadImage.instance(), 'img');
93+
94+
Simulate.load(img);
95+
96+
const loadedWrapper = findRenderedDOMComponentWithClass(lazyLoadImage.instance(), 'lazy-load-image-loaded');
97+
98+
expect(loadedWrapper.style.getPropertyValue('background-image')).toEqual('');
99+
expect(loadedWrapper.style.getPropertyValue('background-size')).toEqual('');
100+
});
101+
86102
it('adds the effect class', function() {
87103
const lazyLoadImage = mount(
88104
<LazyLoadImage effect="blur" />

0 commit comments

Comments
 (0)