2017-12-08 19:36:03 +00:00
|
|
|
import {View} from 'react-native';
|
|
|
|
import { Provider } from 'react-redux';
|
|
|
|
|
|
|
|
import { createStore, combineReducers } from 'redux';
|
|
|
|
|
2018-02-16 16:02:04 +00:00
|
|
|
const reducers = combineReducers({login:() => ({user: {}}), settings:() => ({})});
|
2017-12-08 19:36:03 +00:00
|
|
|
const store = createStore(reducers);
|
|
|
|
|
2017-08-18 15:50:48 +00:00
|
|
|
import React from 'react';
|
2017-09-01 19:40:55 +00:00
|
|
|
import RoomItem from '../app/presentation/RoomItem';
|
2017-08-18 15:50:48 +00:00
|
|
|
|
|
|
|
// Note: test renderer must be required after react-native.
|
|
|
|
import renderer from 'react-test-renderer';
|
|
|
|
|
2017-11-08 20:46:59 +00:00
|
|
|
const date = new Date(2017, 10, 10, 10);
|
|
|
|
|
2017-08-22 12:01:53 +00:00
|
|
|
jest.mock('react-native-img-cache', () => { return { CachedImage: 'View' } });
|
2017-08-18 15:50:48 +00:00
|
|
|
|
|
|
|
it('renders correctly', () => {
|
2017-12-08 19:36:03 +00:00
|
|
|
expect(renderer.create(<Provider store={store}><View><RoomItem type="d" _updatedAt={date} name="name" /></View></Provider>).toJSON()).toMatchSnapshot();
|
2017-08-18 15:50:48 +00:00
|
|
|
});
|
2017-08-22 01:43:29 +00:00
|
|
|
|
|
|
|
it('render unread', () => {
|
2017-12-08 19:36:03 +00:00
|
|
|
expect(renderer.create(<Provider store={store}><View><RoomItem type="d" _updatedAt={date} name="name" unread={1} /></View></Provider>).toJSON()).toMatchSnapshot();
|
2017-08-22 01:43:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('render unread +999', () => {
|
2017-12-08 19:36:03 +00:00
|
|
|
expect(renderer.create(<Provider store={store}><View><RoomItem type="d" _updatedAt={date} name="name" unread={1000} /></View></Provider>).toJSON()).toMatchSnapshot();
|
2017-08-22 01:43:29 +00:00
|
|
|
});
|
2017-08-22 18:22:55 +00:00
|
|
|
|
|
|
|
it('render no icon', () => {
|
2017-12-08 19:36:03 +00:00
|
|
|
expect(renderer.create(<Provider store={store}><View><RoomItem type="X" _updatedAt={date} name="name" /></View></Provider>).toJSON()).toMatchSnapshot();
|
2017-08-22 18:22:55 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('render private group', () => {
|
2017-12-08 19:36:03 +00:00
|
|
|
expect(renderer.create(<Provider store={store}><View><RoomItem type="g" _updatedAt={date} name="private-group" /> </View></Provider>).toJSON()).toMatchSnapshot();
|
2017-08-22 18:22:55 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('render channel', () => {
|
2017-12-08 19:36:03 +00:00
|
|
|
expect(renderer.create(<Provider store={store}><View><RoomItem type="c" _updatedAt={date} name="general" /></View></Provider>).toJSON()).toMatchSnapshot();
|
2017-08-22 18:22:55 +00:00
|
|
|
});
|