1import React from 'react';
2import { mount } from 'enzyme';
3import { SourceView, SourceViewProps, BlocksRow } from './SourceView';
4import { sampleAPIResponse } from './__testdata__/testdata';
5import { sortBlocks } from './helpers';
6
7const sorted = sortBlocks(sampleAPIResponse.data.blocks, sampleAPIResponse.data.label);
8const source = 'prometheus_one';
9
10describe('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  };
20
21  const sourceView = mount(<SourceView {...defaultProps} />);
22
23  it('renders a paragraph with title', () => {
24    const title = sourceView.find('div > span');
25    expect(title).toHaveLength(1);
26    expect(title.text()).toEqual(source);
27  });
28
29  it('renders a row for each unique resolution and compaction level pair', () => {
30    const rows = sourceView.find(BlocksRow);
31    expect(rows).toHaveLength(Object.keys(sorted[source]).length);
32  });
33});
34