You've already forked mattermost-webapp
mirror of
https://github.com/zerotier/mattermost-webapp.git
synced 2026-05-22 16:23:25 -07:00
4453f86f87
* general feature complete. changed functionality is scoped to create_post.jsx * textbox now keeps focus after slash command error. submitting twice will force submit the message. update create_post test * move "message submit error" into its own component * handle server error type correctly, and fix some i18n references * move tests to be next to source code * fix nested `FormattedMessage` components
56 lines
1.7 KiB
React
56 lines
1.7 KiB
React
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import React from 'react';
|
|
import {shallow} from 'enzyme';
|
|
|
|
import MessageSubmitError from 'components/message_submit_error.jsx';
|
|
|
|
describe('components/MessageSubmitError', () => {
|
|
const baseProps = {
|
|
handleSubmit: jest.fn(),
|
|
};
|
|
|
|
it('should display the submit link if the error is for an invalid slash command', () => {
|
|
const error = {
|
|
message: 'No command found',
|
|
server_error_id: 'api.command.execute_command.not_found.app_error',
|
|
};
|
|
const submittedMessage = 'fakecommand some text';
|
|
|
|
const props = {
|
|
...baseProps,
|
|
error,
|
|
submittedMessage,
|
|
};
|
|
|
|
const wrapper = shallow(
|
|
<MessageSubmitError {...props}/>
|
|
);
|
|
|
|
expect(wrapper.find('[id="message_submit_error.invalidCommand"]').exists()).toBe(true);
|
|
expect(wrapper.text()).not.toEqual('No command found');
|
|
});
|
|
|
|
it('should not display the submit link if the error is not for an invalid slash command', () => {
|
|
const error = {
|
|
message: 'Some server error',
|
|
server_error_id: 'api.other_error',
|
|
};
|
|
const submittedMessage = '/fakecommand some text';
|
|
|
|
const props = {
|
|
...baseProps,
|
|
error,
|
|
submittedMessage,
|
|
};
|
|
|
|
const wrapper = shallow(
|
|
<MessageSubmitError {...props}/>
|
|
);
|
|
|
|
expect(wrapper.find('[id="message_submit_error.invalidCommand"]').exists()).toBe(false);
|
|
expect(wrapper.text()).toEqual('Some server error');
|
|
});
|
|
});
|