RealOrangeOne / react-native-mock

A fully mocked and test-friendly version of react native (maintainers wanted)
MIT License
571 stars 153 forks source link

Add NavigationCard constants #107

Closed dingbat closed 7 years ago

dingbat commented 7 years ago

Currently any use with react-router-native fails because it expects several classes/functions to be defined on NavigationExperimental.Card (see in react-native here).

It also expects forHorizontal and forVertical in CardStackStyleInterpolator and forHorizontal in PagerStyleInterpolator, all on load.

This PR adds all those mocks to the existing NavigationExperimental mock.

Thanks for the hard work put into this library!

dingbat commented 7 years ago

@RealOrangeOne Lint wanted it written as a stateless function. Let me know what you think.

RealOrangeOne commented 7 years ago

@dingbat I understand why. Instead of adding the keys after the fact, could you use the static block in a component to define them, would be much easier, and it shouldnt complain then

dingbat commented 7 years ago

@RealOrangeOne I'm not sure what you meant by using a static block, but I added the constants as static fields on the component class. Thanks for the good feedback.

RealOrangeOne commented 7 years ago

Almost done. Can you remove the brackets around the fat-arrow functions, keep things a little cleaner, as they aren't needed. Then we can ship! :shipit:

dingbat commented 7 years ago

Oh, the parentheses? They are needed because the functions return an empty object, so it's ambiguous with the omitted-bracket function syntax.

Actually now that I think about it, the library doesn't call the functions, it just references/asserts that they're present, so we could even just do:

static CardStackPanResponder = CardStackPanResponder;
static CardStackStyleInterpolator = {
  forHorizontal: {},
  forVertical: {},
};
static PagerPanResponder = PagerPanResponder;
static PagerStyleInterpolator = {
  forHorizontal: {},
};
RealOrangeOne commented 7 years ago

ah, didnt realise they were returning empty objects. thought they werent returning. In that case! :shipit: