Explore: adds MetaInfoText tests

pull/21854/head
Lukas Siatka 5 years ago committed by Lukas Siatka
parent 61b5471ed8
commit f7fe4d4865
  1. 34
      public/app/features/explore/MetaInfoText.test.tsx
  2. 18
      public/app/features/explore/__snapshots__/MetaInfoText.test.tsx.snap

@ -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…
Cancel
Save