mirror of https://github.com/prometheus/prometheus
Browse Source
* feat: add search to metrics explorer Signed-off-by: mtfoley <mtfoley.mae@gmail.com> * fix: ui-lint and ui-build errors Signed-off-by: mtfoley <mtfoley.mae@gmail.com> * feat: use @nexucis/fuzzy Signed-off-by: mtfoley <mtfoley.mae@gmail.com> * chore: code style and delete commented test Signed-off-by: mtfoley <mtfoley.mae@gmail.com> * rename Props to MetricsExplorerProps Signed-off-by: mtfoley <mtfoley.mae@gmail.com>pull/9702/head
Matthew
3 years ago
committed by
GitHub
2 changed files with 84 additions and 11 deletions
@ -0,0 +1,46 @@
|
||||
import * as React from 'react'; |
||||
import { mount, ReactWrapper } from 'enzyme'; |
||||
import MetricsExplorer from './MetricsExplorer'; |
||||
import { Input } from 'reactstrap'; |
||||
|
||||
describe('MetricsExplorer', () => { |
||||
const spyInsertAtCursor = jest.fn().mockImplementation((value: string) => { |
||||
value = value; |
||||
}); |
||||
const metricsExplorerProps = { |
||||
show: true, |
||||
updateShow: (show: boolean): void => { |
||||
show = show; |
||||
}, |
||||
metrics: ['go_test_1', 'prometheus_test_1'], |
||||
insertAtCursor: spyInsertAtCursor, |
||||
}; |
||||
|
||||
let metricsExplorer: ReactWrapper; |
||||
beforeEach(() => { |
||||
metricsExplorer = mount(<MetricsExplorer {...metricsExplorerProps} />); |
||||
}); |
||||
|
||||
it('renders an Input[type=text]', () => { |
||||
const input = metricsExplorer.find(Input); |
||||
expect(input.prop('type')).toEqual('text'); |
||||
}); |
||||
|
||||
it('lists all metrics in props', () => { |
||||
const metrics = metricsExplorer.find('.metric'); |
||||
expect(metrics).toHaveLength(metricsExplorerProps.metrics.length); |
||||
}); |
||||
|
||||
it('filters metrics with search', () => { |
||||
const input = metricsExplorer.find(Input); |
||||
input.simulate('change', { target: { value: 'go' } }); |
||||
const metrics = metricsExplorer.find('.metric'); |
||||
expect(metrics).toHaveLength(1); |
||||
}); |
||||
|
||||
it('handles click on metric', () => { |
||||
const metric = metricsExplorer.find('.metric').at(0); |
||||
metric.simulate('click'); |
||||
expect(metricsExplorerProps.insertAtCursor).toHaveBeenCalled(); |
||||
}); |
||||
}); |
Loading…
Reference in new issue