-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
6 changed files
with
188 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...ck/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel_wrapper.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { Visualization } from '../../types'; | ||
import { createMockVisualization, createMockFramePublicAPI, FrameMock } from '../mocks'; | ||
import { mountWithIntl as mount } from 'test_utils/enzyme_helpers'; | ||
import { ReactWrapper } from 'enzyme'; | ||
import { WorkspacePanelWrapper, WorkspacePanelWrapperProps } from './workspace_panel_wrapper'; | ||
|
||
describe('workspace_panel_wrapper', () => { | ||
let mockVisualization: jest.Mocked<Visualization>; | ||
let mockFrameAPI: FrameMock; | ||
let instance: ReactWrapper<WorkspacePanelWrapperProps>; | ||
|
||
beforeEach(() => { | ||
mockVisualization = createMockVisualization(); | ||
mockFrameAPI = createMockFramePublicAPI(); | ||
}); | ||
|
||
afterEach(() => { | ||
instance.unmount(); | ||
}); | ||
|
||
it('should render its children', () => { | ||
const MyChild = () => <span>The child elements</span>; | ||
instance = mount( | ||
<WorkspacePanelWrapper | ||
dispatch={jest.fn()} | ||
framePublicAPI={mockFrameAPI} | ||
visualizationState={{}} | ||
activeVisualization={mockVisualization} | ||
emptyExpression={false} | ||
> | ||
<MyChild /> | ||
</WorkspacePanelWrapper> | ||
); | ||
|
||
expect(instance.find(MyChild)).toHaveLength(1); | ||
}); | ||
|
||
it('should call the toolbar renderer if provided', () => { | ||
const renderToolbarMock = jest.fn(); | ||
const visState = { internalState: 123 }; | ||
instance = mount( | ||
<WorkspacePanelWrapper | ||
dispatch={jest.fn()} | ||
framePublicAPI={mockFrameAPI} | ||
visualizationState={visState} | ||
children={<span />} | ||
activeVisualization={{ ...mockVisualization, renderToolbar: renderToolbarMock }} | ||
emptyExpression={false} | ||
/> | ||
); | ||
|
||
expect(renderToolbarMock).toHaveBeenCalledWith(expect.any(Element), { | ||
state: visState, | ||
frame: mockFrameAPI, | ||
setState: expect.anything(), | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters