Revert "reduced views in trigger"
the problem is that we can't measure certain "touchables" e.g. Button
This commit is contained in:
parent
3a3b66010d
commit
089f4f4cf8
|
@ -15,9 +15,10 @@ describe('MenuTrigger', () => {
|
|||
<Text>Trigger Button</Text>
|
||||
</MenuTrigger>
|
||||
);
|
||||
expect(nthChild(output, 0).type).toEqual(TouchableHighlight);
|
||||
expect(nthChild(output, 1).type).toEqual(View);
|
||||
expect(nthChild(output, 2)).toEqual(
|
||||
expect(output.type).toEqual(View);
|
||||
expect(nthChild(output, 1).type).toEqual(TouchableHighlight);
|
||||
expect(nthChild(output, 2).type).toEqual(View);
|
||||
expect(nthChild(output, 3)).toEqual(
|
||||
<Text>Trigger Button</Text>
|
||||
);
|
||||
});
|
||||
|
@ -26,9 +27,9 @@ describe('MenuTrigger', () => {
|
|||
const { output } = render(
|
||||
<MenuTrigger text='Trigger text' />
|
||||
);
|
||||
expect(nthChild(output, 0).type).toEqual(TouchableHighlight);
|
||||
expect(nthChild(output, 1).type).toEqual(View);
|
||||
expect(nthChild(output, 2)).toEqual(
|
||||
expect(nthChild(output, 1).type).toEqual(TouchableHighlight);
|
||||
expect(nthChild(output, 2).type).toEqual(View);
|
||||
expect(nthChild(output, 3)).toEqual(
|
||||
<Text>Trigger text</Text>
|
||||
);
|
||||
});
|
||||
|
@ -45,9 +46,8 @@ describe('MenuTrigger', () => {
|
|||
const { output } = render(
|
||||
<MenuTrigger onRef={onRefSpy} />
|
||||
);
|
||||
const triggerView = nthChild(output, 1);
|
||||
expect(typeof triggerView.ref).toEqual('function');
|
||||
triggerView.ref();
|
||||
expect(typeof output.ref).toEqual('function');
|
||||
output.ref();
|
||||
expect(onRefSpy).toHaveBeenCalled();
|
||||
expect(onRefSpy.calls.count()).toEqual(1);
|
||||
});
|
||||
|
@ -58,7 +58,7 @@ describe('MenuTrigger', () => {
|
|||
);
|
||||
const menuActions = { openMenu: createSpy() };
|
||||
instance.context = { menuActions };
|
||||
nthChild(output, 0).props.onPress();
|
||||
nthChild(output, 1).props.onPress();
|
||||
expect(menuActions.openMenu).toHaveBeenCalledWith('menu1');
|
||||
expect(menuActions.openMenu.calls.count()).toEqual(1);
|
||||
});
|
||||
|
@ -69,7 +69,7 @@ describe('MenuTrigger', () => {
|
|||
);
|
||||
const menuActions = { openMenu: createSpy() };
|
||||
instance.context = { menuActions };
|
||||
nthChild(output, 0).props.onPress();
|
||||
nthChild(output, 1).props.onPress();
|
||||
expect(menuActions.openMenu).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
@ -82,9 +82,9 @@ describe('MenuTrigger', () => {
|
|||
const { output } = render(
|
||||
<MenuTrigger menuName='menu1' text='some text' customStyles={customStyles} />
|
||||
);
|
||||
const touchable = nthChild(output, 0);
|
||||
const view = nthChild(output, 1);
|
||||
const text = nthChild(output, 2);
|
||||
const touchable = nthChild(output, 1);
|
||||
const view = nthChild(output, 2);
|
||||
const text = nthChild(output, 3);
|
||||
expect(normalizeStyle(touchable.props))
|
||||
.toEqual(objectContaining({ underlayColor: 'green' }));
|
||||
expect(normalizeStyle(view.props.style))
|
||||
|
|
|
@ -16,15 +16,17 @@ export default class MenuTrigger extends Component {
|
|||
const onPress = () => !disabled && this._onPress();
|
||||
const { Touchable, defaultTouchableProps } = makeTouchable(customStyles.TriggerTouchableComponent);
|
||||
return (
|
||||
<Touchable
|
||||
onPress={onPress}
|
||||
{...defaultTouchableProps}
|
||||
{...customStyles.triggerTouchable}
|
||||
>
|
||||
<View {...other} style={[customStyles.triggerWrapper, style]} ref={onRef}>
|
||||
{text ? <Text style={customStyles.triggerText}>{text}</Text> : children}
|
||||
</View>
|
||||
</Touchable>
|
||||
<View ref={onRef} collapsable={false}>
|
||||
<Touchable
|
||||
onPress={onPress}
|
||||
{...defaultTouchableProps}
|
||||
{...customStyles.triggerTouchable}
|
||||
>
|
||||
<View {...other} style={[customStyles.triggerWrapper, style]}>
|
||||
{text ? <Text style={customStyles.triggerText}>{text}</Text> : children}
|
||||
</View>
|
||||
</Touchable>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue