|
| 1 | +import React from 'react'; |
| 2 | +import ReactTestUtils from 'react/lib/ReactTestUtils'; |
| 3 | +import Image from '../src/Image'; |
| 4 | + |
| 5 | +describe('Image', function() { |
| 6 | + |
| 7 | + it('should be an image', function() { |
| 8 | + let instance = ReactTestUtils.renderIntoDocument( |
| 9 | + <Image /> |
| 10 | + ); |
| 11 | + let image = React.findDOMNode(instance); |
| 12 | + |
| 13 | + image.nodeName.should.equal('IMG'); |
| 14 | + }); |
| 15 | + |
| 16 | + it('should provide src and alt prop', function() { |
| 17 | + let instance = ReactTestUtils.renderIntoDocument( |
| 18 | + <Image src="image.jpg" alt="this is alt" /> |
| 19 | + ); |
| 20 | + let image = React.findDOMNode(instance); |
| 21 | + |
| 22 | + assert.equal(image.getAttribute('src'), 'image.jpg'); |
| 23 | + assert.equal(image.getAttribute('alt'), 'this is alt'); |
| 24 | + }); |
| 25 | + |
| 26 | + it('should have correct class when responsive prop is set', function() { |
| 27 | + let instance = ReactTestUtils.renderIntoDocument( |
| 28 | + <Image responsive /> |
| 29 | + ); |
| 30 | + let imageClassName = React.findDOMNode(instance).className; |
| 31 | + |
| 32 | + imageClassName.should.match(/\bimg-responsive\b/); |
| 33 | + }); |
| 34 | + |
| 35 | + it('should have correct class when rounded prop is set', function() { |
| 36 | + let instance = ReactTestUtils.renderIntoDocument( |
| 37 | + <Image rounded /> |
| 38 | + ); |
| 39 | + let imageClassName = React.findDOMNode(instance).className; |
| 40 | + |
| 41 | + imageClassName.should.match(/\bimg-rounded\b/); |
| 42 | + }); |
| 43 | + |
| 44 | + it('should have correct class when circle prop is set', function() { |
| 45 | + let instance = ReactTestUtils.renderIntoDocument( |
| 46 | + <Image circle /> |
| 47 | + ); |
| 48 | + let imageClassName = React.findDOMNode(instance).className; |
| 49 | + |
| 50 | + imageClassName.should.match(/\bimg-circle\b/); |
| 51 | + }); |
| 52 | + |
| 53 | + it('should have correct class when thumbnail prop is set', function() { |
| 54 | + let instance = ReactTestUtils.renderIntoDocument( |
| 55 | + <Image thumbnail /> |
| 56 | + ); |
| 57 | + let imageClassName = React.findDOMNode(instance).className; |
| 58 | + |
| 59 | + imageClassName.should.match(/\bimg-thumbnail\b/); |
| 60 | + }); |
| 61 | +}); |
0 commit comments