houdini/javascripts/src/components/common/StandardFieldComponent.spec.tsx

26 lines
853 B
TypeScript
Raw Normal View History

// License: LGPL-3.0-or-later
import * as React from 'react';
import 'jest';
2018-06-29 13:13:31 -05:00
import {shallow} from 'enzyme'
import StandardFieldComponent from './StandardFieldComponent'
import toJson from 'enzyme-to-json';
describe('StandardFieldComponent', () => {
test('works with no children', () => {
var field = shallow(<StandardFieldComponent inError={false} />)
expect(toJson(field)).toMatchSnapshot()
})
test('works with a child', () => {
var field = shallow(<StandardFieldComponent inError={false}><input/></StandardFieldComponent>);
expect(toJson(field)).toMatchSnapshot()
})
test('sets error message properly', () => {
var field = shallow(<StandardFieldComponent inError={true} error={"Something more"}><input/></StandardFieldComponent>);
expect(toJson(field)).toMatchSnapshot()
})
})