import React from 'react';
import 'jest-styled-components';
import 'jest-axe/extend-expect';
import 'regenerator-runtime/runtime';
import { render } from '@testing-library/react';
import { Box } from '../../Box';
import { Grommet } from '../../Grommet';
import { Meter } from '../../Meter';
import { NameValueList } from '../../NameValueList';
import { NameValuePair } from '..';
const data = {
name: 'entry',
location: 'San Francisco',
health: 80,
};
describe('NameValuePair', () => {
test(`should render name when name is typeof string`, () => {
const { container } = render(
{Object.entries(data).map(([name, value]) => (
{value}
))}
,
);
expect(container.firstChild).toMatchSnapshot();
});
test(`should render name when name is JSX Element`, () => {
const { container } = render(
{Object.entries(data).map(([name, value]) => (
{name}
}
>
{value}
))}
,
);
expect(container.firstChild).toMatchSnapshot();
});
test(`should render value when provided as child of type
string or number`, () => {
const { container } = render(
{Object.entries(data).map(([name, value]) => (
{value}
))}
,
);
expect(container.firstChild).toMatchSnapshot();
});
test(`should render value when provided as child of type JSX Element`, () => {
const { container } = render(
{Object.entries(data).map(([name, value]) => {
let renderedValue: any = value;
if (name === 'health' && typeof value === 'number') {
renderedValue = ;
}
return (
{renderedValue}
);
})}
,
);
expect(container.firstChild).toMatchSnapshot();
});
});