mattermost-mobile/app/components/post_draft/uploads/uploads.test.js
Miguel Alatzar 4f4be1b319
[MM-28245] Handle upload files only for top screen (#4761)
* Handle upload files only for top screen

* Return early in handlePasteFiles too
2020-09-01 12:36:51 -07:00

40 lines
1.3 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 '@mm-redux/constants/preferences';
import EphemeralStore from '@store/ephemeral_store';
import Uploads from './uploads';
describe('Uploads', () => {
const baseProps = {
channelId: 'channel-id',
files: [],
filesUploadingForCurrentChannel: true,
handleRemoveLastFile: jest.fn(),
initUploadFiles: jest.fn(),
maxFileSize: 100,
theme: Preferences.THEMES.default,
};
test('handleUploadFiles should return early if screen is not the top screen', async () => {
const topScreenId = 'top-screen';
EphemeralStore.getNavigationTopComponentId = jest.fn(() => (topScreenId));
const props = {
...baseProps,
screenId: `not-${topScreenId}`,
};
const wrapper = shallow(
<Uploads {...props}/>,
);
const instance = wrapper.instance();
instance.handleFileSizeWarning = jest.fn();
await instance.handleUploadFiles([]);
expect(instance.handleFileSizeWarning).not.toHaveBeenCalled();
expect(props.initUploadFiles).not.toHaveBeenCalled();
});
});