GH-6452 Migrate installed_command.jsx to be pure and use Redux (#6903)
* Migrate installed_command.jsx to be pure and use Redux * Add test for InstalledCommand component * Fix failing test and typo * Whoops. Revert back deleted filter * Add filter test * Remove commands related code from /stores/integration_store.jsx
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
b54d134299
Коммит
ea095d6206
83
webapp/tests/components/integrations/installed_command.test.jsx
Обычный файл
83
webapp/tests/components/integrations/installed_command.test.jsx
Обычный файл
@@ -0,0 +1,83 @@
|
||||
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
import React from 'react';
|
||||
import {shallow} from 'enzyme';
|
||||
|
||||
import InstalledCommand from 'components/integrations/components/installed_command.jsx';
|
||||
|
||||
describe('components/integrations/InstalledCommand', () => {
|
||||
const emptyFunction = jest.fn();
|
||||
const command = {
|
||||
id: 'r5tpgt4iepf45jt768jz84djic',
|
||||
display_name: 'test',
|
||||
description: 'test',
|
||||
trigger: 'trigger',
|
||||
auto_complete: 'test',
|
||||
auto_complete_hint: 'test',
|
||||
token: 'testToken',
|
||||
create_at: '1499722850203'
|
||||
};
|
||||
|
||||
test('should match snapshot', () => {
|
||||
const wrapper = shallow(
|
||||
<InstalledCommand
|
||||
team={{
|
||||
name: 'test'
|
||||
}}
|
||||
command={command}
|
||||
onRegenToken={emptyFunction}
|
||||
onDelete={emptyFunction}
|
||||
filter={'trigger'}
|
||||
creator={{
|
||||
username: 'test'
|
||||
}}
|
||||
canChange={true}
|
||||
/>
|
||||
);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should call onRegenToken function', () => {
|
||||
const onRegenToken = jest.fn();
|
||||
const wrapper = shallow(
|
||||
<InstalledCommand
|
||||
team={{
|
||||
name: 'test'
|
||||
}}
|
||||
command={command}
|
||||
onRegenToken={onRegenToken}
|
||||
onDelete={emptyFunction}
|
||||
filter={''}
|
||||
creator={{
|
||||
username: 'test'
|
||||
}}
|
||||
canChange={true}
|
||||
/>
|
||||
);
|
||||
wrapper.find('div.item-actions a').first().simulate('click', {preventDefault() {
|
||||
return jest.fn();
|
||||
}});
|
||||
|
||||
expect(onRegenToken).toBeCalled();
|
||||
});
|
||||
|
||||
test('should filter out command', () => {
|
||||
const wrapper = shallow(
|
||||
<InstalledCommand
|
||||
team={{
|
||||
name: 'test'
|
||||
}}
|
||||
command={command}
|
||||
onRegenToken={emptyFunction}
|
||||
onDelete={emptyFunction}
|
||||
filter={'filter'}
|
||||
creator={{
|
||||
username: 'test'
|
||||
}}
|
||||
canChange={true}
|
||||
/>
|
||||
);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
Ссылка в новой задаче
Block a user