forked from react-bootstrap/react-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFormControlsSpec.js
43 lines (34 loc) · 1.33 KB
/
FormControlsSpec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import React from 'react';
import ReactTestUtils from 'react/lib/ReactTestUtils';
import * as FormControls from '../src/FormControls';
describe('Form Controls', () => {
describe('Static', () => {
it('renders a p element wrapped around the given value', () => {
const instance = ReactTestUtils.renderIntoDocument(
<FormControls.Static value='v' />
);
const result = ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'p');
result.innerHTML.should.equal('v');
});
it('getValue() pulls from either value or children', () => {
let instance = ReactTestUtils.renderIntoDocument(
<FormControls.Static value='v' />
);
instance.getValue().should.equal('v');
instance = ReactTestUtils.renderIntoDocument(
<FormControls.Static>5</FormControls.Static>
);
instance.getValue().should.equal('5');
});
it('throws an error if both value and children are provided', () => {
const testData = { value: 'blah', children: 'meh' };
const result = FormControls.Static.propTypes.children(testData, 'children', 'Static');
result.should.be.instanceOf(Error);
});
it('allows elements as children', () => {
ReactTestUtils.renderIntoDocument(
<FormControls.Static><span>blah</span></FormControls.Static>
);
});
});
});