prometheus

Форк
0
/
MetricsExplorer.test.tsx 
46 строк · 1.4 Кб
1
import * as React from 'react';
2
import { mount, ReactWrapper } from 'enzyme';
3
import MetricsExplorer from './MetricsExplorer';
4
import { Input } from 'reactstrap';
5

6
describe('MetricsExplorer', () => {
7
  const spyInsertAtCursor = jest.fn().mockImplementation((value: string) => {
8
    value = value;
9
  });
10
  const metricsExplorerProps = {
11
    show: true,
12
    updateShow: (show: boolean): void => {
13
      show = show;
14
    },
15
    metrics: ['go_test_1', 'prometheus_test_1'],
16
    insertAtCursor: spyInsertAtCursor,
17
  };
18

19
  let metricsExplorer: ReactWrapper;
20
  beforeEach(() => {
21
    metricsExplorer = mount(<MetricsExplorer {...metricsExplorerProps} />);
22
  });
23

24
  it('renders an Input[type=text]', () => {
25
    const input = metricsExplorer.find(Input);
26
    expect(input.prop('type')).toEqual('text');
27
  });
28

29
  it('lists all metrics in props', () => {
30
    const metrics = metricsExplorer.find('.metric');
31
    expect(metrics).toHaveLength(metricsExplorerProps.metrics.length);
32
  });
33

34
  it('filters metrics with search', () => {
35
    const input = metricsExplorer.find(Input);
36
    input.simulate('change', { target: { value: 'go' } });
37
    const metrics = metricsExplorer.find('.metric');
38
    expect(metrics).toHaveLength(1);
39
  });
40

41
  it('handles click on metric', () => {
42
    const metric = metricsExplorer.find('.metric').at(0);
43
    metric.simulate('click');
44
    expect(metricsExplorerProps.insertAtCursor).toHaveBeenCalled();
45
  });
46
});
47

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.