This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 189
/
Copy pathimage.test.tsx
49 lines (42 loc) · 1.71 KB
/
image.test.tsx
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
import { shallow } from 'enzyme'
import * as React from 'react'
import BootstrapImage from 'react-bootstrap/Image'
import { Image } from '../src'
describe('Image', () => {
it('Image renders itself without crashing', () => {
const src = 'sample-src'
const imageWrapper = shallow(<Image src={src} />)
expect(imageWrapper.find(BootstrapImage)).toHaveLength(1)
})
it('Image can display image', () => {
const src = 'sample-src'
const imageWrapper = shallow(<Image src={src} />)
const bootstrapImage = imageWrapper.find(BootstrapImage)
expect(bootstrapImage.props().src).toEqual(src)
})
it('Image can be rounded', () => {
const src = 'sample-src'
const imageWrapper = shallow(<Image src={src} rounded />)
const bootstrapImage = imageWrapper.find(BootstrapImage)
expect(bootstrapImage.props().rounded).toBe(true)
})
it('Image can be circular', () => {
const src = 'sample-src'
const imageWrapper = shallow(<Image src={src} circle />)
const bootstrapImage = imageWrapper.find(BootstrapImage)
expect(bootstrapImage.props().roundedCircle).toBe(true)
})
it('Image can have a fluid width', () => {
const src = 'sample-src'
const imageWrapper = shallow(<Image src={src} fluid />)
const bootstrapImage = imageWrapper.find(BootstrapImage)
expect(bootstrapImage.props().fluid).toBe(true)
})
it('Image can accept standard img props', () => {
const src = 'sample-src'
const imageWrapper = shallow(<Image src={src} crossOrigin="anonymous" alt="Sample alt" />)
const bootstrapImage = imageWrapper.find(BootstrapImage)
expect(bootstrapImage.props().alt).toBe('Sample alt')
expect(bootstrapImage.props().crossOrigin).toBe('anonymous')
})
})