Fix tests

This commit is contained in:
Chi Vinh Le
2018-09-06 00:06:58 +02:00
parent 31bc5fa913
commit c96112fc8c
39 changed files with 1095 additions and 262 deletions
@@ -1,18 +1,12 @@
import React from "react";
import { hoistStatics, wrapDisplayName } from "recompose";
import * as React from "react";
import {
hoistStatics,
InferableComponentEnhancer,
wrapDisplayName,
} from "recompose";
import { Omit } from "talk-ui/types";
import { TalkContext, TalkContextConsumer } from "./TalkContext";
// Injects props and removes them from the prop requirements.
// Will not pass through the injected props if they are passed in during
// render. Also adds new prop requirements from TNeedsProps.
type InferableComponentEnhancerWithProps<TInjectedProps> = <
P extends TInjectedProps
>(
component: React.ComponentType<P>
) => React.ComponentType<Omit<P, keyof TInjectedProps>>;
/**
* withContext is a HOC wrapper around `TalkContextConsumer`.
* `propsCallback` must be provided which accepts the `TalkContext`
@@ -20,7 +14,7 @@ type InferableComponentEnhancerWithProps<TInjectedProps> = <
*/
function withContext<T>(
propsCallback: (context: TalkContext) => T
): InferableComponentEnhancerWithProps<T> {
): InferableComponentEnhancer<T> {
return hoistStatics<T>(
<U extends T>(WrappedComponent: React.ComponentType<U>) => {
const Component: React.StatelessComponent<any> = props => (
@@ -33,7 +27,7 @@ function withContext<T>(
Component.displayName = wrapDisplayName(WrappedComponent, "withContext");
return Component;
}
) as any;
);
}
export default withContext;