Add activeTab to local state

This commit is contained in:
Chi Vinh Le
2018-09-13 18:29:22 +02:00
parent db483849dd
commit ecc9eadc67
23 changed files with 120 additions and 44 deletions
@@ -0,0 +1,22 @@
import { shallow } from "enzyme";
import React from "react";
import { PropTypesOf } from "talk-framework/types";
import CommentsPane from "./CommentsPane";
it("renders stream", () => {
const props: PropTypesOf<typeof CommentsPane> = {
showPermalinkView: false,
};
const wrapper = shallow(<CommentsPane {...props} />);
expect(wrapper).toMatchSnapshot();
});
it("renders permalink view", () => {
const props: PropTypesOf<typeof CommentsPane> = {
showPermalinkView: true,
};
const wrapper = shallow(<CommentsPane {...props} />);
expect(wrapper).toMatchSnapshot();
});
@@ -0,0 +1,15 @@
import * as React from "react";
import { StatelessComponent } from "react";
import PermalinkViewQuery from "../queries/PermalinkViewQuery";
import StreamQuery from "../queries/StreamQuery";
export interface CommentsPaneProps {
showPermalinkView: boolean;
}
const CommentsPane: StatelessComponent<CommentsPaneProps> = props => {
return props.showPermalinkView ? <PermalinkViewQuery /> : <StreamQuery />;
};
export default CommentsPane;
@@ -0,0 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`renders permalink view 1`] = `<withContext(withLocalStateContainer(PermalinkViewQuery)) />`;
exports[`renders stream 1`] = `<withContext(withLocalStateContainer(StreamQuery)) />`;
@@ -0,0 +1,27 @@
import * as React from "react";
import { StatelessComponent } from "react";
import { graphql, withLocalStateContainer } from "talk-framework/lib/relay";
import { CommentsPaneContainerLocal as Local } from "talk-stream/__generated__/CommentsPaneContainerLocal.graphql";
import CommentsPane from "../components/CommentsPane";
interface InnerProps {
local: Local;
}
const CommentsPaneContainer: StatelessComponent<InnerProps> = ({
local: { commentID },
}) => {
return <CommentsPane showPermalinkView={!!commentID} />;
};
const enhanced = withLocalStateContainer(
graphql`
fragment CommentsPaneContainerLocal on Local {
commentID
}
`
)(CommentsPaneContainer);
export default enhanced;