github.com/thanos-io/thanos@v0.32.5/pkg/ui/react-app/src/thanos/pages/blocks/SourceView.test.tsx (about)

     1  import React from 'react';
     2  import { mount } from 'enzyme';
     3  import { SourceView, SourceViewProps, BlocksRow } from './SourceView';
     4  import { sampleAPIResponse } from './__testdata__/testdata';
     5  import { sortBlocks } from './helpers';
     6  
     7  const sorted = sortBlocks(sampleAPIResponse.data.blocks, sampleAPIResponse.data.label, false);
     8  const source = 'prometheus_one';
     9  
    10  describe('Blocks SourceView', () => {
    11    const defaultProps: SourceViewProps = {
    12      title: source,
    13      data: sorted[source],
    14      selectBlock: (): void => {
    15        // do nothing
    16      },
    17      gridMinTime: 1596096000000,
    18      gridMaxTime: 1595108031471,
    19      blockSearch: '',
    20      compactionLevel: 0,
    21    };
    22  
    23    const sourceView = mount(<SourceView {...defaultProps} />);
    24  
    25    it('renders a paragraph with title', () => {
    26      const title = sourceView.find('div > span');
    27      expect(title).toHaveLength(1);
    28      expect(title.text()).toEqual(source);
    29    });
    30  
    31    it('renders a row for each unique resolution and compaction level pair', () => {
    32      const rows = sourceView.find(BlocksRow);
    33      expect(rows).toHaveLength(Object.keys(sorted[source]).length);
    34    });
    35  });