2020-01-26 22:00:11 -06:00
|
|
|
import React from 'react';
|
2022-03-18 14:44:51 -05:00
|
|
|
import { render, screen } from '@testing-library/react';
|
2020-01-26 22:00:11 -06:00
|
|
|
import { MetaInfoText, MetaItemProps } from './MetaInfoText';
|
|
|
|
describe('MetaInfoText', () => {
|
2022-03-18 14:44:51 -05:00
|
|
|
it('should render component and items', () => {
|
2020-01-26 22:00:11 -06:00
|
|
|
const items: MetaItemProps[] = [
|
|
|
|
{ label: 'label', value: 'value' },
|
|
|
|
{ label: 'label2', value: 'value2' },
|
|
|
|
];
|
|
|
|
|
2022-03-18 14:44:51 -05:00
|
|
|
render(<MetaInfoText metaItems={items} />);
|
|
|
|
expect(screen.getAllByTestId('meta-info-text')).toHaveLength(1);
|
|
|
|
expect(screen.getAllByTestId('meta-info-text-item')).toHaveLength(2);
|
|
|
|
expect(screen.getByText('label:')).toBeInTheDocument();
|
|
|
|
expect(screen.getByText('label2:')).toBeInTheDocument();
|
|
|
|
expect(screen.getByText(/^value$/)).toBeInTheDocument();
|
|
|
|
expect(screen.getByText(/^value2$/)).toBeInTheDocument();
|
2020-01-26 22:00:11 -06:00
|
|
|
});
|
|
|
|
|
2022-03-18 14:44:51 -05:00
|
|
|
it('should render component with no items when the array is empty', () => {
|
2020-01-26 22:00:11 -06:00
|
|
|
const items: MetaItemProps[] = [];
|
2022-03-18 14:44:51 -05:00
|
|
|
render(<MetaInfoText metaItems={items} />);
|
|
|
|
expect(screen.getAllByTestId('meta-info-text')).toHaveLength(1);
|
|
|
|
expect(screen.queryByTestId('meta-info-text-item')).toBeNull();
|
2020-01-26 22:00:11 -06:00
|
|
|
});
|
|
|
|
});
|