This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
type HOCWrapped<PWrapped, PHoc> = React.ComponentClass<PWrapped & PHoc> | React.SFC<PWrapped & PHoc>; | |
const queryString = require("query-string"); | |
import {RouteComponentProps, withRouter} from "react-router"; | |
export interface IQueryStringProps { | |
params: any; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"jest": { | |
"transform": { | |
"^.+\\.css$": "react-scripts-ts/config/jest/cssTransform.js", | |
".(ts|tsx)": "react-scripts-ts/config/jest/typescriptTransform.js", | |
"^(?!.*\\.(css|json)$)": "react-scripts-ts/config/jest/fileTransform.js" | |
}, | |
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", | |
"moduleFileExtensions": [ | |
"ts", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
import {IWithPersonalizationProps, withPersonalization} from "./withPersonalization2"; | |
import {IWithNavigationProps, withNavigation} from "./withNavigation"; | |
// This empty declaration is required | |
interface IWelcomeOwnProps {} | |
type IWelcomeProps = IWelcomeOwnProps & IWithNavigationProps & IWithPersonalizationProps; | |
class Welcome extends React.Component<IWelcomeProps, {}> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
import {shallow, mount} from "enzyme"; | |
import configureStore from "redux-mock-store"; | |
import withPersonalization from "./withPersonalization2"; | |
import {IWithPersonalizationProps} from "./withPersonalization2"; | |
import {Provider} from "react-redux"; | |
// test helpers | |
const middlewares = []; | |
const mockStore = configureStore(middlewares); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
import * as ReactRedux from "react-redux"; | |
export interface IWithPersonalizationProps { | |
name: string; | |
} | |
type HOC<PWrapped, PHoc> = React.ComponentClass<PWrapped & PHoc> | React.SFC<PWrapped & PHoc>; | |
export function withPersonalization<P, S>(Component: HOC<P, IWithPersonalizationProps>): React.ComponentClass<P> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
import {IWithPersonalizationProps, withPersonalization} from "./withPersonalization"; | |
interface IWelcomeOwnProps { | |
onClick: () => void; | |
} | |
export class Welcome extends React.Component<IWelcomeOwnProps & IWithPersonalizationProps, {}> { | |
constructor(props: IWelcomeOwnProps & IWithPersonalizationProps) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
export interface IWithPersonalizationProps { | |
name: string; | |
} | |
type HOCWrapped<P, PHoc> = React.ComponentClass<P & PHoc> | React.SFC<P & PHoc>; | |
export function withPersonalization<P, S>(Component: HOCWrapped<P, IWithPersonalizationProps>): React.ComponentClass<P> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
import {Welcome} from "./welcome"; | |
import {shallow} from "enzyme"; | |
const name = "Tester; | |
describe("<Welcome />", () => { | |
it("renders a greeting from the name", () => { | |
const wrapper = shallow(<Welcome name={name} onClick={() => null} />); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "react"; | |
interface IWelcomeProps { | |
name: string; | |
onClick: () => void; | |
} | |
export class Welcome extends React.Component<IWelcomeProps, {}> { | |
constructor(props: IWelcomeProps) { |