mirror of
https://github.com/wassname/talk.git
synced 2026-07-18 12:40:13 +08:00
Add activeTab to local state
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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)>
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user