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