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,6 +73,15 @@ exports[`render channel 1`] = `
</Text>
</View>
<View
style={
Object {
"flex": 1,
"marginLeft": 16,
"marginRight": 4,
}
}
>
<Text
accessible={true}
allowFontScaling={true}
@ -84,13 +93,31 @@ exports[`render channel 1`] = `
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
"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>
`;
@ -123,6 +150,15 @@ exports[`render no icon 1`] = `
}
testID={undefined}
tvParallaxProperties={undefined}
>
<View
style={
Object {
"flex": 1,
"marginLeft": 16,
"marginRight": 4,
}
}
>
<Text
accessible={true}
@ -135,13 +171,31 @@ exports[`render no icon 1`] = `
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
"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>
`;
@ -174,6 +228,15 @@ exports[`render private group 1`] = `
}
testID={undefined}
tvParallaxProperties={undefined}
>
<View
style={
Object {
"flex": 1,
"marginLeft": 16,
"marginRight": 4,
}
}
>
<Text
accessible={true}
@ -186,13 +249,31 @@ exports[`render private group 1`] = `
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
"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,6 +344,15 @@ exports[`render unread +999 1`] = `
NA
</Text>
</View>
<View
style={
Object {
"flex": 1,
"marginLeft": 16,
"marginRight": 4,
}
}
>
<Text
accessible={true}
allowFontScaling={true}
@ -274,13 +364,31 @@ exports[`render unread +999 1`] = `
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
"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,6 +480,15 @@ exports[`render unread 1`] = `
NA
</Text>
</View>
<View
style={
Object {
"flex": 1,
"marginLeft": 16,
"marginRight": 4,
}
}
>
<Text
accessible={true}
allowFontScaling={true}
@ -383,13 +500,31 @@ exports[`render unread 1`] = `
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
"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,6 +616,15 @@ exports[`renders correctly 1`] = `
NA
</Text>
</View>
<View
style={
Object {
"flex": 1,
"marginLeft": 16,
"marginRight": 4,
}
}
>
<Text
accessible={true}
allowFontScaling={true}
@ -492,12 +636,30 @@ exports[`renders correctly 1`] = `
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
"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,6 +243,15 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
/>
</View>
<View
style={
Object {
"flex": 1,
"marginLeft": 16,
"marginRight": 4,
}
}
>
<Text
accessible={true}
allowFontScaling={true}
@ -254,13 +263,31 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
"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,6 +374,15 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
/>
</View>
<View
style={
Object {
"flex": 1,
"marginLeft": 16,
"marginRight": 4,
}
}
>
<Text
accessible={true}
allowFontScaling={true}
@ -358,13 +394,31 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
"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,6 +505,15 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
/>
</View>
<View
style={
Object {
"flex": 1,
"marginLeft": 16,
"marginRight": 4,
}
}
>
<Text
accessible={true}
allowFontScaling={true}
@ -462,13 +525,31 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
"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,6 +657,15 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
/>
</View>
<View
style={
Object {
"flex": 1,
"marginLeft": 16,
"marginRight": 4,
}
}
>
<Text
accessible={true}
allowFontScaling={true}
@ -587,13 +677,31 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
"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,6 +809,15 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
/>
</View>
<View
style={
Object {
"flex": 1,
"marginLeft": 16,
"marginRight": 4,
}
}
>
<Text
accessible={true}
allowFontScaling={true}
@ -712,13 +829,31 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
"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,6 +961,15 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
/>
</View>
<View
style={
Object {
"flex": 1,
"marginLeft": 16,
"marginRight": 4,
}
}
>
<Text
accessible={true}
allowFontScaling={true}
@ -837,13 +981,31 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
"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,6 +1113,15 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
/>
</View>
<View
style={
Object {
"flex": 1,
"marginLeft": 16,
"marginRight": 4,
}
}
>
<Text
accessible={true}
allowFontScaling={true}
@ -962,13 +1133,31 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
"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,6 +1246,15 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
W
</Text>
</View>
<View
style={
Object {
"flex": 1,
"marginLeft": 16,
"marginRight": 4,
}
}
>
<Text
accessible={true}
allowFontScaling={true}
@ -1068,13 +1266,31 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
"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,6 +1358,15 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
WW
</Text>
</View>
<View
style={
Object {
"flex": 1,
"marginLeft": 16,
"marginRight": 4,
}
}
>
<Text
accessible={true}
allowFontScaling={true}
@ -1153,13 +1378,31 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
"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,6 +1470,15 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
</Text>
</View>
<View
style={
Object {
"flex": 1,
"marginLeft": 16,
"marginRight": 4,
}
}
>
<Text
accessible={true}
allowFontScaling={true}
@ -1238,13 +1490,31 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
"color": "#444",
"flex": 1,
"fontSize": 16,
"marginLeft": 16,
"marginRight": 4,
"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>