make compatible with react-native-web

This commit is contained in:
Johannes 2018-04-05 11:03:04 +02:00
parent 37d0a0f8e1
commit 545441a47a
2 changed files with 20 additions and 1 deletions

View File

@ -70,6 +70,24 @@ describe('helpers test', () => {
expect(defaultTouchableProps).to.be.an('object');
});
it('should create TouchableHighlight for web', () => {
Platform.select.mockImplementationOnce(o => {
return o.web;
});
const { Touchable, defaultTouchableProps } = makeTouchable();
expect(Touchable).to.be.equal(TouchableHighlight);
expect(defaultTouchableProps).to.be.an('object');
});
it('should create TouchableHighlight for windows', () => {
Platform.select.mockImplementationOnce(o => {
return o.windows;
});
const { Touchable, defaultTouchableProps } = makeTouchable();
expect(Touchable).to.be.equal(TouchableHighlight);
expect(defaultTouchableProps).to.be.an('object');
});
it('should return passed component', () => {
const MyTouchable = () => null;
const { Touchable, defaultTouchableProps } = makeTouchable(MyTouchable);

View File

@ -27,8 +27,9 @@ export const makeName = (function() {
*/
export function makeTouchable(TouchableComponent) {
const Touchable = TouchableComponent || Platform.select({
ios: TouchableHighlight,
android: TouchableNativeFeedback,
ios: TouchableHighlight,
web: TouchableHighlight,
windows:TouchableHighlight,
});
let defaultTouchableProps = {};