houdini/javascripts/src/components/common/StandardFieldComponent.spec.tsx
2018-05-22 13:33:35 -05:00

27 lines
No EOL
912 B
TypeScript

// License: LGPL-3.0-or-later
import * as React from 'react';
import 'jest';
import {shallow,render} from 'enzyme'
const TestRenderer = require('react-test-renderer')
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()
})
})