Fix tests

This commit is contained in:
Rodrigo Nascimento 2017-11-08 18:46:59 -02:00
parent 329669f18f
commit 60c7a9b31e
No known key found for this signature in database
GPG Key ID: CFCE33B7B01AC335
4 changed files with 612 additions and 166 deletions

View File

@ -5,28 +5,30 @@ import RoomItem from '../app/presentation/RoomItem';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
const date = new Date(2017, 10, 10, 10);
jest.mock('react-native-img-cache', () => { return { CachedImage: 'View' } });
it('renders correctly', () => {
expect(renderer.create(<RoomItem type="d" name="name" />).toJSON()).toMatchSnapshot();
expect(renderer.create(<RoomItem type="d" _updatedAt={date} name="name" />).toJSON()).toMatchSnapshot();
});
it('render unread', () => {
expect(renderer.create(<RoomItem type="d" name="name" unread={1} />).toJSON()).toMatchSnapshot();
expect(renderer.create(<RoomItem type="d" _updatedAt={date} name="name" unread={1} />).toJSON()).toMatchSnapshot();
});
it('render unread +999', () => {
expect(renderer.create(<RoomItem type="d" name="name" unread={1000} />).toJSON()).toMatchSnapshot();
expect(renderer.create(<RoomItem type="d" _updatedAt={date} name="name" unread={1000} />).toJSON()).toMatchSnapshot();
});
it('render no icon', () => {
expect(renderer.create(<RoomItem type="X" name="name" />).toJSON()).toMatchSnapshot();
expect(renderer.create(<RoomItem type="X" _updatedAt={date} name="name" />).toJSON()).toMatchSnapshot();
});
it('render private group', () => {
expect(renderer.create(<RoomItem type="g" name="private-group" /> ).toJSON()).toMatchSnapshot();
expect(renderer.create(<RoomItem type="g" _updatedAt={date} name="private-group" /> ).toJSON()).toMatchSnapshot();
});
it('render channel', () => {
expect(renderer.create(<RoomItem type="c" name="general" />).toJSON()).toMatchSnapshot();
expect(renderer.create(<RoomItem type="c" _updatedAt={date} name="general" />).toJSON()).toMatchSnapshot();
});

View File

@ -73,24 +73,51 @@ exports[`render channel 1`] = `
</Text>
</View>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
<View
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
}
}
>
general
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"height": 16,
"paddingTop": 10,
}
}
>
general
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#888",
"flex": 1,
"fontSize": 10,
"height": 10,
}
}
>
2017-11-10T10:00:00-02:00
</Text>
</View>
</View>
`;
@ -124,24 +151,51 @@ exports[`render no icon 1`] = `
testID={undefined}
tvParallaxProperties={undefined}
>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
<View
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
}
}
>
name
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"height": 16,
"paddingTop": 10,
}
}
>
name
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#888",
"flex": 1,
"fontSize": 10,
"height": 10,
}
}
>
2017-11-10T10:00:00-02:00
</Text>
</View>
</View>
`;
@ -175,24 +229,51 @@ exports[`render private group 1`] = `
testID={undefined}
tvParallaxProperties={undefined}
>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
<View
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
}
}
>
private-group
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"height": 16,
"paddingTop": 10,
}
}
>
private-group
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#888",
"flex": 1,
"fontSize": 10,
"height": 10,
}
}
>
2017-11-10T10:00:00-02:00
</Text>
</View>
</View>
`;
@ -263,24 +344,51 @@ exports[`render unread +999 1`] = `
NA
</Text>
</View>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
<View
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
}
}
>
name
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"height": 16,
"paddingTop": 10,
}
}
>
name
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#888",
"flex": 1,
"fontSize": 10,
"height": 10,
}
}
>
2017-11-10T10:00:00-02:00
</Text>
</View>
<Text
accessible={true}
allowFontScaling={true}
@ -372,24 +480,51 @@ exports[`render unread 1`] = `
NA
</Text>
</View>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
<View
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
}
}
>
name
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"height": 16,
"paddingTop": 10,
}
}
>
name
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#888",
"flex": 1,
"fontSize": 10,
"height": 10,
}
}
>
2017-11-10T10:00:00-02:00
</Text>
</View>
<Text
accessible={true}
allowFontScaling={true}
@ -481,23 +616,50 @@ exports[`renders correctly 1`] = `
NA
</Text>
</View>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
<View
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
}
}
>
name
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"height": 16,
"paddingTop": 10,
}
}
>
name
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#888",
"flex": 1,
"fontSize": 10,
"height": 10,
}
}
>
2017-11-10T10:00:00-02:00
</Text>
</View>
</View>
`;

View File

@ -243,24 +243,51 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
/>
</View>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
<View
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
}
}
>
rocket.cat
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"height": 16,
"paddingTop": 10,
}
}
>
rocket.cat
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#888",
"flex": 1,
"fontSize": 10,
"height": 10,
}
}
>
2017-11-10T10:00:00-02:00
</Text>
</View>
</View>
<View
accessibilityComponentType={undefined}
@ -347,24 +374,51 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
/>
</View>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
<View
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
}
}
>
rocket.cat
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"height": 16,
"paddingTop": 10,
}
}
>
rocket.cat
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#888",
"flex": 1,
"fontSize": 10,
"height": 10,
}
}
>
2017-11-10T10:00:00-02:00
</Text>
</View>
</View>
<View
accessibilityComponentType={undefined}
@ -451,24 +505,51 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
/>
</View>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
<View
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
}
}
>
rocket.cat
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"height": 16,
"paddingTop": 10,
}
}
>
rocket.cat
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#888",
"flex": 1,
"fontSize": 10,
"height": 10,
}
}
>
2017-11-10T10:00:00-02:00
</Text>
</View>
<Text
accessible={true}
allowFontScaling={true}
@ -576,24 +657,51 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
/>
</View>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
<View
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
}
}
>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"height": 16,
"paddingTop": 10,
}
}
>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#888",
"flex": 1,
"fontSize": 10,
"height": 10,
}
}
>
2017-11-10T10:00:00-02:00
</Text>
</View>
<Text
accessible={true}
allowFontScaling={true}
@ -701,24 +809,51 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
/>
</View>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
<View
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
}
}
>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"height": 16,
"paddingTop": 10,
}
}
>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#888",
"flex": 1,
"fontSize": 10,
"height": 10,
}
}
>
2017-11-10T10:00:00-02:00
</Text>
</View>
<Text
accessible={true}
allowFontScaling={true}
@ -826,24 +961,51 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
/>
</View>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
<View
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
}
}
>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"height": 16,
"paddingTop": 10,
}
}
>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#888",
"flex": 1,
"fontSize": 10,
"height": 10,
}
}
>
2017-11-10T10:00:00-02:00
</Text>
</View>
<Text
accessible={true}
allowFontScaling={true}
@ -951,24 +1113,51 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
/>
</View>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
<View
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
}
}
>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"height": 16,
"paddingTop": 10,
}
}
>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#888",
"flex": 1,
"fontSize": 10,
"height": 10,
}
}
>
2017-11-10T10:00:00-02:00
</Text>
</View>
<Text
accessible={true}
allowFontScaling={true}
@ -1057,24 +1246,51 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
W
</Text>
</View>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
<View
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
}
}
>
W
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"height": 16,
"paddingTop": 10,
}
}
>
W
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#888",
"flex": 1,
"fontSize": 10,
"height": 10,
}
}
>
2017-11-10T10:00:00-02:00
</Text>
</View>
</View>
<View
accessibilityComponentType={undefined}
@ -1142,24 +1358,51 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
WW
</Text>
</View>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
<View
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
}
}
>
WW
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"height": 16,
"paddingTop": 10,
}
}
>
WW
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#888",
"flex": 1,
"fontSize": 10,
"height": 10,
}
}
>
2017-11-10T10:00:00-02:00
</Text>
</View>
</View>
<View
accessibilityComponentType={undefined}
@ -1227,24 +1470,51 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
</Text>
</View>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
<View
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
}
}
>
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 16,
"height": 16,
"paddingTop": 10,
}
}
>
</Text>
<Text
accessible={true}
allowFontScaling={true}
disabled={false}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#888",
"flex": 1,
"fontSize": 10,
"height": 10,
}
}
>
2017-11-10T10:00:00-02:00
</Text>
</View>
</View>
</View>
</RCTScrollView>

View File

@ -3,62 +3,74 @@ import { ScrollView } from 'react-native';
import RoomItem from '../../../app/presentation/RoomItem';
const date = new Date(2017, 10, 10, 10);
export default (
<ScrollView>
<RoomItem
type='d'
name='rocket.cat'
_updatedAt={date}
baseUrl='https://demo.rocket.chat'
/>
<RoomItem
type='d'
unread={0}
_updatedAt={date}
name='rocket.cat'
baseUrl='https://demo.rocket.chat'
/>
<RoomItem
type='d'
unread={1}
_updatedAt={date}
name='rocket.cat'
baseUrl='https://demo.rocket.chat'
/>
<RoomItem
type='d'
unread={9}
_updatedAt={date}
name="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries"
baseUrl='https://demo.rocket.chat'
/>
<RoomItem
type='d'
unread={99}
_updatedAt={date}
name="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries"
baseUrl='https://demo.rocket.chat'
/>
<RoomItem
type='d'
unread={100}
_updatedAt={date}
name="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries"
baseUrl='https://demo.rocket.chat'
/>
<RoomItem
type='d'
unread={100000}
_updatedAt={date}
name="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries"
baseUrl='https://demo.rocket.chat'
/>
<RoomItem
type='d'
name='W'
_updatedAt={date}
unread={-100}
/>
<RoomItem
type='d'
name='WW'
_updatedAt={date}
unread={-100}
/>
<RoomItem
type='d'
name=''
_updatedAt={date}
unread={-100}
/>
</ScrollView>