|
| 1 | +/* |
| 2 | + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
| 3 | + * or more contributor license agreements. Licensed under the Elastic License |
| 4 | + * 2.0 and the Server Side Public License, v 1; you may not use this file except |
| 5 | + * in compliance with, at your election, the Elastic License 2.0 or the Server |
| 6 | + * Side Public License, v 1. |
| 7 | + */ |
| 8 | + |
| 9 | +import { mount as enzymeMount, ReactWrapper } from 'enzyme'; |
| 10 | +import React from 'react'; |
| 11 | +import { ServicesProvider, SharedUXServices } from '../../../../services'; |
| 12 | +import { servicesFactory } from '../../../../services/mocks'; |
| 13 | + |
| 14 | +import { SolutionToolbarButton } from './primary'; |
| 15 | + |
| 16 | +describe('<SolutionToolbarButton />', () => { |
| 17 | + let services: SharedUXServices; |
| 18 | + let mount: (element: JSX.Element) => ReactWrapper; |
| 19 | + |
| 20 | + beforeEach(() => { |
| 21 | + services = servicesFactory(); |
| 22 | + mount = (element: JSX.Element) => |
| 23 | + enzymeMount(<ServicesProvider {...services}>{element}</ServicesProvider>); |
| 24 | + }); |
| 25 | + |
| 26 | + afterEach(() => { |
| 27 | + jest.resetAllMocks(); |
| 28 | + }); |
| 29 | + |
| 30 | + test('is rendered', () => { |
| 31 | + const component = mount(<SolutionToolbarButton label="test" />); |
| 32 | + |
| 33 | + expect(component).toMatchSnapshot(); |
| 34 | + }); |
| 35 | + test('it can be passed a functional onClick handler', () => { |
| 36 | + const mockHandler = jest.fn(); |
| 37 | + const component = mount(<SolutionToolbarButton label="withOnClick" onClick={mockHandler} />); |
| 38 | + component.simulate('click'); |
| 39 | + expect(mockHandler).toHaveBeenCalled(); |
| 40 | + }); |
| 41 | +}); |
0 commit comments