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
+2 -10
View File
@@ -5,17 +5,9 @@ import { PropTypesOf } from "talk-framework/types";
import App from "./App";
it("renders stream", () => {
it("renders comments", () => {
const props: PropTypesOf<typeof App> = {
showPermalinkView: false,
};
const wrapper = shallow(<App {...props} />);
expect(wrapper).toMatchSnapshot();
});
it("renders permalink view", () => {
const props: PropTypesOf<typeof App> = {
showPermalinkView: true,
activeTab: "COMMENTS",
};
const wrapper = shallow(<App {...props} />);
expect(wrapper).toMatchSnapshot();
+10 -8
View File
@@ -3,20 +3,22 @@ import { StatelessComponent } from "react";
import { Flex } from "talk-ui/components";
import PermalinkViewQuery from "../tabs/comments/queries/PermalinkViewQuery";
import StreamQuery from "../tabs/comments/queries/StreamQuery";
import CommentsPaneContainer from "../tabs/comments/containers/CommentsPaneContainer";
import * as styles from "./App.css";
export interface AppProps {
showPermalinkView: boolean;
activeTab: "COMMENTS" | "%future added value";
}
const App: StatelessComponent<AppProps> = props => {
const view = props.showPermalinkView ? (
<PermalinkViewQuery />
) : (
<StreamQuery />
);
let view: React.ReactElement<any>;
switch (props.activeTab) {
case "COMMENTS":
view = <CommentsPaneContainer />;
break;
default:
throw new Error(`Unknown tab ${props.activeTab}`);
}
return (
<Flex justifyContent="center" className={styles.root}>
{view}
@@ -1,19 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`renders permalink view 1`] = `
exports[`renders comments 1`] = `
<withPropsOnChange(Flex)
className="App-root"
justifyContent="center"
>
<withContext(withLocalStateContainer(PermalinkViewQuery)) />
</withPropsOnChange(Flex)>
`;
exports[`renders stream 1`] = `
<withPropsOnChange(Flex)
className="App-root"
justifyContent="center"
>
<withContext(withLocalStateContainer(StreamQuery)) />
<withContext(withLocalStateContainer(CommentsPaneContainer)) />
</withPropsOnChange(Flex)>
`;