diff --git a/tests/components/get_link_modal.test.jsx b/tests/components/get_link_modal.test.jsx new file mode 100644 index 000000000000..d0cbb258ecd1 --- /dev/null +++ b/tests/components/get_link_modal.test.jsx @@ -0,0 +1,58 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +import React from 'react'; + +import {shallow} from 'enzyme'; +import {Modal} from 'react-bootstrap'; + +import GetLinkModal from 'components/get_link_modal.jsx'; + +describe('components/GetLinkModal', () => { + test('should match snapshot when all props is set', () => { + function emptyFunction() {} //eslint-disable-line no-empty-function + + const wrapper = shallow( + + ); + + expect(wrapper).toMatchSnapshot(); + }); + + test('should match snapshot when helpText is not set', () => { + function emptyFunction() {} //eslint-disable-line no-empty-function + + const wrapper = shallow( + + ); + + expect(wrapper).toMatchSnapshot(); + }); + + test('should have called onHide', () => { + const onHide = jest.fn(); + + const wrapper = shallow( + + ); + + wrapper.find(Modal).first().props().onHide(); + expect(onHide).toHaveBeenCalledTimes(1); + }); +}); diff --git a/tests/setup.js b/tests/setup.js index 19e8da8f6750..aad7e7c18984 100644 --- a/tests/setup.js +++ b/tests/setup.js @@ -5,3 +5,18 @@ import Adapter from 'enzyme-adapter-react-15'; import {configure} from 'enzyme'; configure({adapter: new Adapter()}); + +var documentMock = (function() { + const supportedCommands = ['copy']; + + return { + queryCommandSupported(cmd) { + return supportedCommands.includes(cmd); + }, + execCommand(cmd) { + return supportedCommands.includes(cmd); + } + }; +}()); + +Object.defineProperty(window, 'document', {value: documentMock});