forked from react-bootstrap/react-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImageSpec.js
62 lines (49 loc) · 1.81 KB
/
ImageSpec.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import React from 'react';
import ReactTestUtils from 'react/lib/ReactTestUtils';
import ReactDOM from 'react-dom';
import Image from '../src/Image';
describe('Image', () => {
it('should be an image', () => {
let instance = ReactTestUtils.renderIntoDocument(
<Image />
);
let image = ReactDOM.findDOMNode(instance);
image.nodeName.should.equal('IMG');
});
it('should provide src and alt prop', () => {
let instance = ReactTestUtils.renderIntoDocument(
<Image src="image.jpg" alt="this is alt" />
);
let image = ReactDOM.findDOMNode(instance);
assert.equal(image.getAttribute('src'), 'image.jpg');
assert.equal(image.getAttribute('alt'), 'this is alt');
});
it('should have correct class when responsive prop is set', () => {
let instance = ReactTestUtils.renderIntoDocument(
<Image responsive />
);
let imageClassName = ReactDOM.findDOMNode(instance).className;
imageClassName.should.match(/\bimg-responsive\b/);
});
it('should have correct class when rounded prop is set', () => {
let instance = ReactTestUtils.renderIntoDocument(
<Image rounded />
);
let imageClassName = ReactDOM.findDOMNode(instance).className;
imageClassName.should.match(/\bimg-rounded\b/);
});
it('should have correct class when circle prop is set', () => {
let instance = ReactTestUtils.renderIntoDocument(
<Image circle />
);
let imageClassName = ReactDOM.findDOMNode(instance).className;
imageClassName.should.match(/\bimg-circle\b/);
});
it('should have correct class when thumbnail prop is set', () => {
let instance = ReactTestUtils.renderIntoDocument(
<Image thumbnail />
);
let imageClassName = ReactDOM.findDOMNode(instance).className;
imageClassName.should.match(/\bimg-thumbnail\b/);
});
});