@@ -4,6 +4,7 @@ import Input from '../src/Input';
44import Button from '../src/Button' ;
55import DropdownButton from '../src/DropdownButton' ;
66import MenuItem from '../src/MenuItem' ;
7+ import Glyphicon from '../src/Glyphicon' ;
78import { shouldWarn } from './helpers' ;
89
910describe ( 'Input' , function ( ) {
@@ -279,4 +280,56 @@ describe('Input', function () {
279280 let node = React . findDOMNode ( ReactTestUtils . findRenderedDOMComponentWithTag ( instance , 'input' ) ) ;
280281 assert . isNotNull ( node . getAttribute ( 'disabled' ) ) ;
281282 } ) ;
283+
284+ context ( 'when Input listens to feedback' , function ( ) {
285+ it ( 'renders success feedback as Glyphicon' , function ( ) {
286+ let instance = ReactTestUtils . renderIntoDocument (
287+ < Input hasFeedback = { true } bsStyle = "success" />
288+ ) ;
289+
290+ assert . ok ( ReactTestUtils . findRenderedDOMComponentWithClass ( instance , 'glyphicon' ) ) ;
291+ assert . ok ( ReactTestUtils . findRenderedDOMComponentWithClass ( instance , 'glyphicon-ok' ) ) ;
292+ } ) ;
293+
294+ it ( 'renders warning feedback as Glyphicon' , function ( ) {
295+ let instance = ReactTestUtils . renderIntoDocument (
296+ < Input hasFeedback = { true } bsStyle = "warning" />
297+ ) ;
298+
299+ assert . ok ( ReactTestUtils . findRenderedDOMComponentWithClass ( instance , 'glyphicon' ) ) ;
300+ assert . ok ( ReactTestUtils . findRenderedDOMComponentWithClass ( instance , 'glyphicon-warning-sign' ) ) ;
301+ } ) ;
302+
303+ it ( 'renders error feedback as Glyphicon' , function ( ) {
304+ let instance = ReactTestUtils . renderIntoDocument (
305+ < Input hasFeedback = { true } bsStyle = "error" />
306+ ) ;
307+
308+ assert . ok ( ReactTestUtils . findRenderedDOMComponentWithClass ( instance , 'glyphicon' ) ) ;
309+ assert . ok ( ReactTestUtils . findRenderedDOMComponentWithClass ( instance , 'glyphicon-remove' ) ) ;
310+ } ) ;
311+
312+ context ( 'when using feedbackIcon' , function ( ) {
313+ it ( 'uses the feedbackIcon' , function ( ) {
314+ let customIcon = < Glyphicon glyph = "star" /> ;
315+
316+ let instance = ReactTestUtils . renderIntoDocument (
317+ < Input feedbackIcon = { customIcon } hasFeedback = { true } bsStyle = "success" />
318+ ) ;
319+
320+ assert . ok ( ReactTestUtils . findRenderedDOMComponentWithClass ( instance , 'glyphicon' ) ) ;
321+ assert . ok ( ReactTestUtils . findRenderedDOMComponentWithClass ( instance , 'glyphicon-star' ) ) ;
322+ } ) ;
323+
324+ it ( 'adds the .form-control-feedback class for Glyphicons' , function ( ) {
325+ let customIcon = < Glyphicon glyph = "star" /> ;
326+
327+ let instance = ReactTestUtils . renderIntoDocument (
328+ < Input feedbackIcon = { customIcon } hasFeedback = { true } bsStyle = "success" />
329+ ) ;
330+
331+ assert . ok ( ReactTestUtils . findRenderedDOMComponentWithClass ( instance , 'form-control-feedback' ) ) ;
332+ } ) ;
333+ } ) ;
334+ } ) ;
282335} ) ;
0 commit comments