Skip to content

Commit

Permalink
Update AddResultButton to open flyout
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Mar 18, 2021
1 parent a624858 commit a2fc5c5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* 2.0.
*/

import { setMockActions } from '../../../../../__mocks__';

import React from 'react';

import { shallow, ShallowWrapper } from 'enzyme';
Expand All @@ -14,9 +16,14 @@ import { EuiButton } from '@elastic/eui';
import { AddResultButton } from './';

describe('AddResultButton', () => {
const actions = {
openFlyout: jest.fn(),
};

let wrapper: ShallowWrapper;

beforeAll(() => {
setMockActions(actions);
wrapper = shallow(<AddResultButton />);
});

Expand All @@ -26,6 +33,6 @@ describe('AddResultButton', () => {

it('opens the add result flyout on click', () => {
wrapper.find(EuiButton).simulate('click');
// TODO: assert on logic action
expect(actions.openFlyout).toHaveBeenCalled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@

import React from 'react';

import { useActions } from 'kea';

import { EuiButton } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

import { AddResultLogic } from './';

export const AddResultButton: React.FC = () => {
const { openFlyout } = useActions(AddResultLogic);

return (
<EuiButton onClick={() => {} /* TODO */} iconType="plusInCircle" size="s" fill>
<EuiButton onClick={openFlyout} iconType="plusInCircle" size="s" fill>
{i18n.translate('xpack.enterpriseSearch.appSearch.engine.curations.addResult.buttonLabel', {
defaultMessage: 'Add result manually',
})}
Expand Down

0 comments on commit a2fc5c5

Please sign in to comment.