import * as React from 'react';
import { shallow } from 'enzyme';
import BasicInput from './BasicInput';
import TestComponentPropUtils from '../../../utils/TestComponentPropUtils';
import { Icons } from '../../icons/Icons'
describe('BasicInput', () => {
it('renders without crashing', () => {
shallow();
});
it('contains a regular input by default', () => {
const component = shallow();
expect(component.exists('input[type="text"]')).toBe(true);
expect(component.exists('input[type="password"]')).toBe(false);
});
it('renders basic react props like id, className, and style as element attributes', () => {
const shallowWrapper = shallow();
TestComponentPropUtils.expectsBasicReactProps(shallowWrapper, false);
});
it('renders name attribute correctly', () => {
const component = shallow();
expect(component.exists('[name="FormName"]')).toBe(true);
});
it('renders an icon and error message for an invalid input', () => {
const component = shallow(
} invalidMessage="input is erroring" />
);
expect(component.containsMatchingElement()).toBe(true);
expect(component.contains('input is erroring')).toBe(true);
});
it('renders only the error message if no icon provided', () => {
const component = shallow();
expect(component.html().match('svg')).toBeNull();
expect(component.contains('input is erroring')).toBe(true);
});
it('does not render an error message if input is valid', () => {
const component = shallow();
expect(component.contains('input is erroring')).toBe(false);
});
});