mirror of
https://github.com/wassname/talk.git
synced 2026-07-18 12:40:13 +08:00
Updated tests and latest changes
This commit is contained in:
@@ -1,24 +1,30 @@
|
||||
import { Environment } from "relay-runtime";
|
||||
|
||||
import { LOCAL_ID } from "talk-framework/lib/relay/withLocalStateContainer";
|
||||
import { TalkContext } from "talk-framework/lib/bootstrap";
|
||||
import { createMutationContainer } from "talk-framework/lib/relay";
|
||||
import { signOff, SignOffInput } from "talk-framework/rest";
|
||||
import { SignOffInput } from "talk-framework/rest";
|
||||
import { commitLocalUpdate, Environment } from "relay-runtime";
|
||||
|
||||
export type SignOffMutation = (input: SignOffInput) => Promise<void>;
|
||||
|
||||
export async function commit(
|
||||
environment: Environment,
|
||||
input: SignOffInput,
|
||||
{ rest, localStorage }: TalkContext
|
||||
{ localStorage }: TalkContext
|
||||
) {
|
||||
try {
|
||||
await signOff(rest, input);
|
||||
return commitLocalUpdate(environment, store => {
|
||||
const record = store.get(LOCAL_ID)!;
|
||||
record.setValue("", "authToken");
|
||||
localStorage.removeItem("authToken");
|
||||
} catch (error) {
|
||||
localStorage.removeItem("authToken");
|
||||
// tslint:disable-next-line:no-console
|
||||
console.error("error", error);
|
||||
}
|
||||
|
||||
// Force gc to trigger.
|
||||
environment
|
||||
.retain({
|
||||
dataID: "tmp",
|
||||
node: { selections: [] },
|
||||
variables: {},
|
||||
})
|
||||
.dispose();
|
||||
});
|
||||
}
|
||||
|
||||
export const withSignOffMutation = createMutationContainer("signOff", commit);
|
||||
|
||||
@@ -9,6 +9,7 @@ exports[`renders correctly 1`] = `
|
||||
<withContext(createMutationContainer(withContext(createMutationContainer(withContext(withLocalStateContainer(UserBoxContainer)))))) />
|
||||
<withContext(createMutationContainer(PostCommentFormContainer))
|
||||
assetID="asset-id"
|
||||
signedIn={false}
|
||||
/>
|
||||
<withPropsOnChange(Flex)
|
||||
aria-live="polite"
|
||||
@@ -70,6 +71,7 @@ exports[`when there is more disables load more button 1`] = `
|
||||
<withContext(createMutationContainer(withContext(createMutationContainer(withContext(withLocalStateContainer(UserBoxContainer)))))) />
|
||||
<withContext(createMutationContainer(PostCommentFormContainer))
|
||||
assetID="asset-id"
|
||||
signedIn={false}
|
||||
/>
|
||||
<withPropsOnChange(Flex)
|
||||
aria-live="polite"
|
||||
@@ -145,6 +147,7 @@ exports[`when there is more renders a load more button 1`] = `
|
||||
<withContext(createMutationContainer(withContext(createMutationContainer(withContext(withLocalStateContainer(UserBoxContainer)))))) />
|
||||
<withContext(createMutationContainer(PostCommentFormContainer))
|
||||
assetID="asset-id"
|
||||
signedIn={false}
|
||||
/>
|
||||
<withPropsOnChange(Flex)
|
||||
aria-live="polite"
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
import { PermalinkViewQueryLocal as Local } from "talk-stream/__generated__/PermalinkViewQueryLocal.graphql";
|
||||
|
||||
import PermalinkViewContainer from "../containers/PermalinkViewContainer";
|
||||
import { Spinner } from "talk-ui/components";
|
||||
|
||||
interface InnerProps {
|
||||
local: Local;
|
||||
@@ -29,7 +30,7 @@ export const render = ({
|
||||
if (props) {
|
||||
return <PermalinkViewContainer comment={props.comment} />;
|
||||
}
|
||||
return <div>Loading</div>;
|
||||
return <Spinner />;
|
||||
};
|
||||
|
||||
const PermalinkViewQuery: StatelessComponent<InnerProps> = ({
|
||||
|
||||
@@ -14,6 +14,7 @@ import { StreamQueryLocal as Local } from "talk-stream/__generated__/StreamQuery
|
||||
|
||||
import StreamContainer from "../containers/StreamContainer";
|
||||
import { StatelessComponent } from "enzyme";
|
||||
import { Spinner } from "talk-ui/components";
|
||||
|
||||
interface InnerProps {
|
||||
local: Local;
|
||||
@@ -25,11 +26,10 @@ export const render = ({ error, props }: ReadyState<StreamQueryResponse>) => {
|
||||
}
|
||||
|
||||
if (props) {
|
||||
console.log(props);
|
||||
return <StreamContainer asset={props.asset} user={props.me} />;
|
||||
}
|
||||
|
||||
return <div>Loading</div>;
|
||||
return <Spinner />;
|
||||
};
|
||||
|
||||
const StreamQuery: StatelessComponent<InnerProps> = ({
|
||||
|
||||
@@ -6,11 +6,7 @@ exports[`renders error 1`] = `
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`renders loading 1`] = `
|
||||
<div>
|
||||
Loading
|
||||
</div>
|
||||
`;
|
||||
exports[`renders loading 1`] = `<withPropsOnChange(Spinner) />`;
|
||||
|
||||
exports[`renders permalink view container 1`] = `
|
||||
<withContext(withContext(createMutationContainer(Relay(PermalinkViewContainer))))
|
||||
|
||||
@@ -28,6 +28,7 @@ exports[`loads more comments 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Sign in
|
||||
</button>
|
||||
@@ -40,6 +41,7 @@ exports[`loads more comments 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Register
|
||||
</button>
|
||||
@@ -68,8 +70,9 @@ exports[`loads more comments 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Sign In and join the conversation
|
||||
Sign in and join the conversation
|
||||
</button>
|
||||
</form>
|
||||
<div
|
||||
@@ -240,6 +243,7 @@ exports[`renders comment stream 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Sign in
|
||||
</button>
|
||||
@@ -252,6 +256,7 @@ exports[`renders comment stream 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Register
|
||||
</button>
|
||||
@@ -280,8 +285,9 @@ exports[`renders comment stream 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Sign In and join the conversation
|
||||
Sign in and join the conversation
|
||||
</button>
|
||||
</form>
|
||||
<div
|
||||
@@ -387,6 +393,7 @@ exports[`renders comment stream 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Load More
|
||||
</button>
|
||||
|
||||
@@ -22,6 +22,7 @@ exports[`renders permalink view 1`] = `
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
target="_parent"
|
||||
type="button"
|
||||
>
|
||||
Show all Comments
|
||||
</a>
|
||||
@@ -99,6 +100,7 @@ exports[`show all comments 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Sign in
|
||||
</button>
|
||||
@@ -111,6 +113,7 @@ exports[`show all comments 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Register
|
||||
</button>
|
||||
@@ -139,8 +142,9 @@ exports[`show all comments 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Sign In and join the conversation
|
||||
Sign in and join the conversation
|
||||
</button>
|
||||
</form>
|
||||
<div
|
||||
|
||||
@@ -22,6 +22,7 @@ exports[`renders permalink view with unknown asset 1`] = `
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
target="_parent"
|
||||
type="button"
|
||||
>
|
||||
Show all Comments
|
||||
</a>
|
||||
|
||||
+5
-1
@@ -22,6 +22,7 @@ exports[`renders permalink view with unknown comment 1`] = `
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
target="_parent"
|
||||
type="button"
|
||||
>
|
||||
Show all Comments
|
||||
</a>
|
||||
@@ -63,6 +64,7 @@ exports[`show all comments 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Sign in
|
||||
</button>
|
||||
@@ -75,6 +77,7 @@ exports[`show all comments 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Register
|
||||
</button>
|
||||
@@ -103,8 +106,9 @@ exports[`show all comments 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Sign In and join the conversation
|
||||
Sign in and join the conversation
|
||||
</button>
|
||||
</form>
|
||||
<div
|
||||
|
||||
@@ -28,6 +28,7 @@ exports[`renders comment stream 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Sign in
|
||||
</button>
|
||||
@@ -40,6 +41,7 @@ exports[`renders comment stream 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Register
|
||||
</button>
|
||||
@@ -68,8 +70,9 @@ exports[`renders comment stream 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Sign In and join the conversation
|
||||
Sign in and join the conversation
|
||||
</button>
|
||||
</form>
|
||||
<div
|
||||
|
||||
@@ -28,6 +28,7 @@ exports[`renders comment stream 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Sign in
|
||||
</button>
|
||||
@@ -40,6 +41,7 @@ exports[`renders comment stream 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Register
|
||||
</button>
|
||||
@@ -68,8 +70,9 @@ exports[`renders comment stream 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Sign In and join the conversation
|
||||
Sign in and join the conversation
|
||||
</button>
|
||||
</form>
|
||||
<div
|
||||
|
||||
@@ -28,6 +28,7 @@ exports[`renders comment stream 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Sign in
|
||||
</button>
|
||||
@@ -40,6 +41,7 @@ exports[`renders comment stream 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Register
|
||||
</button>
|
||||
@@ -68,8 +70,9 @@ exports[`renders comment stream 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Sign In and join the conversation
|
||||
Sign in and join the conversation
|
||||
</button>
|
||||
</form>
|
||||
<div
|
||||
@@ -176,6 +179,7 @@ exports[`renders comment stream 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Show All Replies
|
||||
</button>
|
||||
@@ -220,6 +224,7 @@ exports[`show all replies 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Sign in
|
||||
</button>
|
||||
@@ -232,6 +237,7 @@ exports[`show all replies 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Register
|
||||
</button>
|
||||
@@ -260,8 +266,9 @@ exports[`show all replies 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Sign In and join the conversation
|
||||
Sign in and join the conversation
|
||||
</button>
|
||||
</form>
|
||||
<div
|
||||
|
||||
@@ -9,6 +9,7 @@ exports[`renders as anchor 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Push Me
|
||||
</a>
|
||||
@@ -23,6 +24,7 @@ exports[`renders correctly 1`] = `
|
||||
onMouseOut={[Function]}
|
||||
onMouseOver={[Function]}
|
||||
onTouchEnd={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Push Me
|
||||
</button>
|
||||
|
||||
@@ -84,7 +84,6 @@ const TextField: StatelessComponent<TextFieldProps> = props => {
|
||||
|
||||
TextField.defaultProps = {
|
||||
color: "regular",
|
||||
fullWidth: true,
|
||||
placeholder: "",
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user