forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from dej611/lens/thresholds-tests
Threshold tests
- Loading branch information
Showing
20 changed files
with
1,554 additions
and
270 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
71 changes: 71 additions & 0 deletions
71
...lugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_settings.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,71 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { | ||
createMockFramePublicAPI, | ||
createMockVisualization, | ||
mountWithProvider, | ||
} from '../../../mocks'; | ||
import { Visualization } from '../../../types'; | ||
import { LayerSettings } from './layer_settings'; | ||
|
||
describe('LayerSettings', () => { | ||
let mockVisualization: jest.Mocked<Visualization>; | ||
const frame = createMockFramePublicAPI(); | ||
|
||
function getDefaultProps() { | ||
return { | ||
activeVisualization: mockVisualization, | ||
layerConfigProps: { | ||
layerId: 'myLayer', | ||
state: {}, | ||
frame, | ||
dateRange: { fromDate: 'now-7d', toDate: 'now' }, | ||
activeData: frame.activeData, | ||
setState: jest.fn(), | ||
}, | ||
}; | ||
} | ||
|
||
beforeEach(() => { | ||
mockVisualization = { | ||
...createMockVisualization(), | ||
id: 'testVis', | ||
visualizationTypes: [ | ||
{ | ||
icon: 'empty', | ||
id: 'testVis', | ||
label: 'TEST1', | ||
groupLabel: 'testVisGroup', | ||
}, | ||
], | ||
}; | ||
}); | ||
|
||
it('should render nothing with no custom renderer nor description', async () => { | ||
// @ts-expect-error | ||
mockVisualization.getDescription.mockReturnValue(undefined); | ||
const { instance } = await mountWithProvider(<LayerSettings {...getDefaultProps()} />); | ||
expect(instance.html()).toBe(null); | ||
}); | ||
|
||
it('should render a static header if visualization has only a description value', async () => { | ||
mockVisualization.getDescription.mockReturnValue({ | ||
icon: 'myIcon', | ||
label: 'myVisualizationType', | ||
}); | ||
const { instance } = await mountWithProvider(<LayerSettings {...getDefaultProps()} />); | ||
expect(instance.find('StaticHeader').first().prop('label')).toBe('myVisualizationType'); | ||
}); | ||
|
||
it('should call the custom renderer if available', async () => { | ||
mockVisualization.renderLayerHeader = jest.fn(); | ||
await mountWithProvider(<LayerSettings {...getDefaultProps()} />); | ||
expect(mockVisualization.renderLayerHeader).toHaveBeenCalled(); | ||
}); | ||
}); |
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
Oops, something went wrong.