From ea095d6206ad8bb9b1b1ffbf74584669a24f1ca8 Mon Sep 17 00:00:00 2001 From: 94117nl Date: Thu, 3 Aug 2017 08:25:07 -0500 Subject: 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 --- .../__snapshots__/installed_command.test.jsx.snap | 103 +++++++++++++++++++++ .../integrations/installed_command.test.jsx | 83 +++++++++++++++++ 2 files changed, 186 insertions(+) create mode 100644 webapp/tests/components/integrations/__snapshots__/installed_command.test.jsx.snap create mode 100644 webapp/tests/components/integrations/installed_command.test.jsx (limited to 'webapp/tests') diff --git a/webapp/tests/components/integrations/__snapshots__/installed_command.test.jsx.snap b/webapp/tests/components/integrations/__snapshots__/installed_command.test.jsx.snap new file mode 100644 index 000000000..910b35e25 --- /dev/null +++ b/webapp/tests/components/integrations/__snapshots__/installed_command.test.jsx.snap @@ -0,0 +1,103 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`components/integrations/InstalledCommand should filter out command 1`] = `null`; + +exports[`components/integrations/InstalledCommand should match snapshot 1`] = ` +
+
+
+ + test + + + - /trigger test + +
+
+ + test + +
+
+ + + +
+
+ + + +
+
+
+ + + + - + + + + - + +
+
+`; diff --git a/webapp/tests/components/integrations/installed_command.test.jsx b/webapp/tests/components/integrations/installed_command.test.jsx new file mode 100644 index 000000000..b38d04754 --- /dev/null +++ b/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( + + ); + expect(wrapper).toMatchSnapshot(); + }); + + test('should call onRegenToken function', () => { + const onRegenToken = jest.fn(); + const wrapper = shallow( + + ); + wrapper.find('div.item-actions a').first().simulate('click', {preventDefault() { + return jest.fn(); + }}); + + expect(onRegenToken).toBeCalled(); + }); + + test('should filter out command', () => { + const wrapper = shallow( + + ); + expect(wrapper).toMatchSnapshot(); + }); +}); -- cgit v1.2.3-1-g7c22