The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/plugins/datasource/grafana-azure-monitor-datas.../components/ResourcePicker/NestedRow.test.tsx

58 lines
1.5 KiB

import { render, screen } from '@testing-library/react';
import React from 'react';
import NestedRow from './NestedRow';
import { ResourceRowType } from './types';
const defaultProps = {
row: {
id: '1',
uri: 'some-uri',
name: '1',
type: ResourceRowType.Resource,
typeLabel: '1',
},
level: 0,
selectedRows: [],
requestNestedRows: jest.fn(),
onRowSelectedChange: jest.fn(),
selectableEntryTypes: [],
};
describe('NestedRow', () => {
it('should not display a checkbox when the type of row is empty', () => {
render(
<table>
<tbody>
<NestedRow {...defaultProps} />
</tbody>
</table>
);
const box = screen.queryByRole('checkbox');
expect(box).not.toBeInTheDocument();
});
it('should display a checkbox when the type of row is in selectableEntryTypes', () => {
render(
<table>
<tbody>
<NestedRow {...defaultProps} selectableEntryTypes={[ResourceRowType.Resource]} />
</tbody>
</table>
);
const box = screen.queryByRole('checkbox');
expect(box).toBeInTheDocument();
});
it('should not display a checkbox when the type of row is not in selectableEntryTypes', () => {
render(
<table>
<tbody>
<NestedRow {...defaultProps} selectableEntryTypes={[ResourceRowType.ResourceGroup]} />
</tbody>
</table>
);
const box = screen.queryByRole('checkbox');
expect(box).not.toBeInTheDocument();
});
});