forked from Ivasoft/mattermost-mobile
* Fix ChannelLoader prop warning
* Missing semicolon
(cherry picked from commit f577685264)
Co-authored-by: Miguel Alatzar <migbot@users.noreply.github.com>
This commit is contained in:
@@ -42,7 +42,7 @@ export default class ChannelLoader extends PureComponent {
|
||||
style: CustomPropTypes.Style,
|
||||
theme: PropTypes.object.isRequired,
|
||||
height: PropTypes.number,
|
||||
retryLoad: PropTypes.func.isRequired,
|
||||
retryLoad: PropTypes.func,
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
@@ -75,8 +75,10 @@ export default class ChannelLoader extends PureComponent {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.stillLoadingTimeout = setTimeout(this.showIndicator, 10000);
|
||||
this.retryLoadInterval = setInterval(this.props.retryLoad, 10000);
|
||||
if (this.props.retryLoad) {
|
||||
this.stillLoadingTimeout = setTimeout(this.showIndicator, 10000);
|
||||
this.retryLoadInterval = setInterval(this.props.retryLoad, 10000);
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
||||
@@ -14,7 +14,6 @@ describe('ChannelLoader', () => {
|
||||
const baseProps = {
|
||||
channelIsLoading: true,
|
||||
theme: Preferences.THEMES.default,
|
||||
retryLoad: jest.fn(),
|
||||
};
|
||||
|
||||
test('should match snapshot', () => {
|
||||
@@ -23,15 +22,26 @@ describe('ChannelLoader', () => {
|
||||
});
|
||||
|
||||
test('should call setTimeout and setInterval for showIndicator and retryLoad on mount', () => {
|
||||
const wrapper = shallow(<ChannelLoader {...baseProps}/>);
|
||||
const instance = wrapper.instance();
|
||||
shallow(<ChannelLoader {...baseProps}/>);
|
||||
expect(setTimeout).not.toHaveBeenCalled();
|
||||
expect(setInterval).not.toHaveBeenCalled();
|
||||
|
||||
const props = {
|
||||
...baseProps,
|
||||
retryLoad: jest.fn(),
|
||||
};
|
||||
const wrapper = shallow(<ChannelLoader {...props}/>);
|
||||
const instance = wrapper.instance();
|
||||
expect(setTimeout).toHaveBeenCalledWith(instance.showIndicator, 10000);
|
||||
expect(setInterval).toHaveBeenCalledWith(baseProps.retryLoad, 10000);
|
||||
expect(setInterval).toHaveBeenCalledWith(props.retryLoad, 10000);
|
||||
});
|
||||
|
||||
test('should clear timer and interval on unmount', () => {
|
||||
const wrapper = shallow(<ChannelLoader {...baseProps}/>);
|
||||
const props = {
|
||||
...baseProps,
|
||||
retryLoad: jest.fn(),
|
||||
};
|
||||
const wrapper = shallow(<ChannelLoader {...props}/>);
|
||||
const instance = wrapper.instance();
|
||||
instance.componentWillUnmount();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user