diff options
author | n1aba <n1aba.github@gmail.com> | 2017-08-18 08:42:10 -0500 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2017-08-18 09:42:10 -0400 |
commit | f40f41ed536edb76c9873c0cdd5dc8685b0f950f (patch) | |
tree | b53f73c702c4e40cb9a5140b8cd3e5f2da9aaf46 /webapp/tests/components/integrations/add_oauth_app.test.jsx | |
parent | 9097289c2ce2b719a5aa0f9d567594f2b6a7e30b (diff) | |
download | chat-f40f41ed536edb76c9873c0cdd5dc8685b0f950f.tar.gz chat-f40f41ed536edb76c9873c0cdd5dc8685b0f950f.tar.bz2 chat-f40f41ed536edb76c9873c0cdd5dc8685b0f950f.zip |
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
Diffstat (limited to 'webapp/tests/components/integrations/add_oauth_app.test.jsx')
-rw-r--r-- | webapp/tests/components/integrations/add_oauth_app.test.jsx | 81 |
1 files changed, 81 insertions, 0 deletions
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( + <AddOAuthApp + team={team} + addOAuthAppRequest={{ + status: 'not_started', + error: null + }} + actions={{addOAuthApp: emptyFunction}} + /> + ); + + expect(wrapper).toMatchSnapshot(); + }); + + test('should match snapshot, displays client error', () => { + const wrapper = shallow( + <AddOAuthApp + team={team} + addOAuthAppRequest={{ + status: 'not_started', + error: null + }} + actions={{addOAuthApp: emptyFunction}} + /> + ); + + 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( + <AddOAuthApp + team={team} + addOAuthAppRequest={{ + status: 'not_started', + error: null + }} + actions={{addOAuthApp}} + /> + ); + + 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 |