forked from testshallpass/react-native-dropdownalert
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImageView-test.js
33 lines (32 loc) · 1.35 KB
/
ImageView-test.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
import 'react-native';
import React from 'react';
import ImageView from '../imageview';
import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import errorImage from '../assets/error.png';
test('renders imageview with uri source', () => {
const wrapper = shallow(<ImageView source={'https://facebook.github.io/react/img/logo_og.png'} />);
const tree = toJson(wrapper);
expect(tree).toMatchSnapshot();
});
test('renders imageview with number source', () => {
const wrapper = shallow(<ImageView source={errorImage} />);
const tree = toJson(wrapper);
expect(tree).toMatchSnapshot();
});
test('renders imageview without source', () => {
const wrapper = shallow(<ImageView source={null} />);
const tree = toJson(wrapper);
expect(tree).toEqual("");
});
test('renders imageview with style and source', () => {
const wrapper = shallow(<ImageView style={{ width: 44, height: 44 }} source={'https://facebook.github.io/react/img/logo_og.png'} />);
const tree = toJson(wrapper);
expect(tree.props.style).toBeDefined();
});
test('renders imageview to have width and height without it defined in style', () => {
const wrapper = shallow(<ImageView style={{ flex: 1 }} source={'https://facebook.github.io/react/img/logo_og.png'} />);
const tree = toJson(wrapper);
expect(tree.props.style.width).toBe(36);
expect(tree.props.style.height).toBe(36);
});