From f40f41ed536edb76c9873c0cdd5dc8685b0f950f Mon Sep 17 00:00:00 2001 From: n1aba Date: Fri, 18 Aug 2017 08:42:10 -0500 Subject: PLT-6443 Migrate add_oauth_app.jsx to be pure and use Redux (#7232) * Migrate add_oauth_app.jsx to be pure and use Redux, add tests * Remove unused flux code for OAuthApps --- .../components/integrations/add_oauth_app.test.jsx | 81 ++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 webapp/tests/components/integrations/add_oauth_app.test.jsx (limited to 'webapp/tests/components/integrations/add_oauth_app.test.jsx') diff --git a/webapp/tests/components/integrations/add_oauth_app.test.jsx b/webapp/tests/components/integrations/add_oauth_app.test.jsx new file mode 100644 index 000000000..11e743ff5 --- /dev/null +++ b/webapp/tests/components/integrations/add_oauth_app.test.jsx @@ -0,0 +1,81 @@ +// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import React from 'react'; +import {shallow} from 'enzyme'; + +import AddOAuthApp from 'components/integrations/components/add_oauth_app/add_oauth_app.jsx'; + +describe('components/integrations/AddOAuthApp', () => { + const emptyFunction = jest.fn(); + const team = { + id: 'dbcxd9wpzpbpfp8pad78xj12pr', + name: 'test' + }; + + test('should match snapshot', () => { + const wrapper = shallow( + + ); + + expect(wrapper).toMatchSnapshot(); + }); + + test('should match snapshot, displays client error', () => { + const wrapper = shallow( + + ); + + wrapper.find('.btn-primary').simulate('click', {preventDefault() { + return jest.fn(); + }}); + + expect(wrapper).toMatchSnapshot(); + }); + + test('should call addOAuthApp function', () => { + const addOAuthApp = jest.genMockFunction().mockImplementation( + () => { + return new Promise((resolve) => { + process.nextTick(() => resolve()); + }); + } + ); + + const wrapper = shallow( + + ); + + wrapper.find('#name').simulate('change', {target: {value: 'name'}}); + wrapper.find('#description').simulate('change', {target: {value: 'description'}}); + wrapper.find('#homepage').simulate('change', {target: {value: 'http://test.com'}}); + wrapper.find('#callbackUrls').simulate('change', {target: {value: 'http://callback.com'}}); + + wrapper.find('.btn-primary').simulate('click', {preventDefault() { + return jest.fn(); + }}); + + expect(addOAuthApp).toBeCalled(); + }); +}); \ No newline at end of file -- cgit v1.2.3-1-g7c22