mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: adds MetaInfoText tests
This commit is contained in:
parent
61b5471ed8
commit
f7fe4d4865
34
public/app/features/explore/MetaInfoText.test.tsx
Normal file
34
public/app/features/explore/MetaInfoText.test.tsx
Normal file
@ -0,0 +1,34 @@
|
||||
import React from 'react';
|
||||
import { shallow, render } from 'enzyme';
|
||||
import { MetaInfoText, MetaItemProps } from './MetaInfoText';
|
||||
describe('MetaInfoText', () => {
|
||||
it('should render component', () => {
|
||||
const items: MetaItemProps[] = [
|
||||
{ label: 'label', value: 'value' },
|
||||
{ label: 'label2', value: 'value2' },
|
||||
];
|
||||
const wrapper = shallow(<MetaInfoText metaItems={items} />);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should render items', () => {
|
||||
const items: MetaItemProps[] = [
|
||||
{ label: 'label', value: 'value' },
|
||||
{ label: 'label2', value: 'value2' },
|
||||
];
|
||||
|
||||
const wrapper = render(<MetaInfoText metaItems={items} />);
|
||||
expect(wrapper.find('label')).toBeTruthy();
|
||||
expect(wrapper.find('value')).toBeTruthy();
|
||||
expect(wrapper.find('label2')).toBeTruthy();
|
||||
expect(wrapper.find('value2')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should render no items when the array is empty', () => {
|
||||
const items: MetaItemProps[] = [];
|
||||
|
||||
const wrapper = shallow(<MetaInfoText metaItems={items} />);
|
||||
expect(wrapper.find('div').exists()).toBeTruthy();
|
||||
expect(wrapper.find('div').children()).toHaveLength(0);
|
||||
});
|
||||
});
|
@ -0,0 +1,18 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`MetaInfoText should render component 1`] = `
|
||||
<div
|
||||
className="css-mi7ebz"
|
||||
>
|
||||
<Component
|
||||
key="0-label"
|
||||
label="label"
|
||||
value="value"
|
||||
/>
|
||||
<Component
|
||||
key="1-label2"
|
||||
label="label2"
|
||||
value="value2"
|
||||
/>
|
||||
</div>
|
||||
`;
|
Loading…
Reference in New Issue
Block a user