/**
* @jest-environment jsdom
*/
/* eslint-disable wpcalypso/jsx-classname-namespace */
import { matchers } from '@emotion/jest';
import { ThemeProvider } from '@emotion/react';
import { render } from '@testing-library/react';
import FormFieldAnnotation from '../components/form-field-annotation';
// Add the custom matchers provided by '@emotion/jest'
expect.extend( matchers );
const theme = {
colors: {
textColor: 'blue',
textColorLight: 'lightblue',
borderColor: 'black',
error: 'red',
},
weights: { bold: '15pt' },
};
describe( 'FormFieldAnnotation', () => {
describe( 'with no error and not disabled', () => {
let MyFormFieldAnnotation = null;
beforeEach( () => {
MyFormFieldAnnotation = () => (
child contents
);
} );
it( 'renders the description string', () => {
const { getAllByText } = render( );
expect( getAllByText( 'A description' )[ 0 ] ).toBeInTheDocument();
} );
it( 'does not render the error string', () => {
const { queryAllByText } = render( );
expect( queryAllByText( 'An Error Message' )[ 0 ] ).toBeUndefined();
} );
} );
describe( 'with error and not disabled', () => {
let MyFormFieldAnnotation = null;
beforeEach( () => {
MyFormFieldAnnotation = () => (
child contents
);
} );
it( 'does not render the description string', () => {
const { queryAllByText } = render( );
expect( queryAllByText( 'A description' )[ 0 ] ).toBeUndefined();
} );
it( 'renders the error string', () => {
const { getAllByText } = render( );
expect( getAllByText( 'An Error Message' )[ 0 ] ).toBeInTheDocument();
} );
} );
} );