* MM-19037 Updated Progressive Image Loader Set the return for the listener to return a null for hte loader images, stopping the component from thinking it had a loaded image on a failure. Also enabled the thumbnail to make an additional attempt to load when it receives the null response. * MM-19037 Updated Eslint Eslint issue resolved * MM-19037 Add Unit Tests Added Unit tests * empty commit
43 lines
No EOL
1.2 KiB
JavaScript
43 lines
No EOL
1.2 KiB
JavaScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import React from 'react';
|
|
import {shallow} from 'enzyme';
|
|
|
|
import Preferences from 'mattermost-redux/constants/preferences';
|
|
|
|
import ProgressiveImage from './progressive_image';
|
|
|
|
describe('ProgressiveImage', () => {
|
|
const baseProps = {
|
|
isBackgroundImage: false,
|
|
defaultSource: 0,
|
|
filename: 'defaultImage',
|
|
imageUri: 'https://images.com/image.png',
|
|
onError: jest.fn(),
|
|
resizeMethod: 'auto',
|
|
resizeMode: 'contain',
|
|
theme: Preferences.THEMES.default,
|
|
thumbnailUri: 'https://images.com/image.png',
|
|
tintDefaultSource: false,
|
|
};
|
|
|
|
test('should match snapshot when just a image loads', () => {
|
|
const wrapper = shallow(
|
|
<ProgressiveImage {...baseProps}/>
|
|
);
|
|
expect(wrapper.getElement()).toMatchSnapshot();
|
|
});
|
|
|
|
test('should match snapshot when no thumbnail', () => {
|
|
const props = {
|
|
...baseProps,
|
|
thumbnailUri: null,
|
|
};
|
|
|
|
const wrapper = shallow(
|
|
<ProgressiveImage {...props}/>
|
|
);
|
|
expect(wrapper.getElement()).toMatchSnapshot();
|
|
});
|
|
}); |