diff --git a/src/core/client/stream/components/Comment/Comment.spec.tsx b/src/core/client/stream/components/Comment/Comment.spec.tsx index 3fe7c0ab1..cae068012 100644 --- a/src/core/client/stream/components/Comment/Comment.spec.tsx +++ b/src/core/client/stream/components/Comment/Comment.spec.tsx @@ -1,28 +1,17 @@ import { shallow } from "enzyme"; import React from "react"; +import { PropTypesOf } from "talk-framework/types"; + import Comment from "./Comment"; it("renders username and body", () => { - const props = { + const props: PropTypesOf = { author: { username: "Marvin", }, body: "Woof", - createdAt: new Date("December 17, 1995 03:24:00").toISOString(), - }; - const wrapper = shallow(); - expect(wrapper).toMatchSnapshot(); -}); - -it("renders with gutterBottom", () => { - const props = { - author: { - username: "Marvin", - }, - body: "Woof", - createdAt: new Date("December 17, 1995 03:24:00").toISOString(), - gutterBottom: true, + createdAt: "1995-12-17T03:24:00.000Z", }; const wrapper = shallow(); expect(wrapper).toMatchSnapshot(); diff --git a/src/core/client/stream/components/Comment/Timestamp.spec.tsx b/src/core/client/stream/components/Comment/Timestamp.spec.tsx new file mode 100644 index 000000000..4a276b762 --- /dev/null +++ b/src/core/client/stream/components/Comment/Timestamp.spec.tsx @@ -0,0 +1,14 @@ +import { shallow } from "enzyme"; +import React from "react"; + +import { PropTypesOf } from "talk-framework/types"; + +import Timestamp from "./Timestamp"; + +it("renders correctly", () => { + const props: PropTypesOf = { + children: "1995-12-17T03:24:00.000Z", + }; + const wrapper = shallow(); + expect(wrapper).toMatchSnapshot(); +}); diff --git a/src/core/client/stream/components/Comment/TopBar.spec.tsx b/src/core/client/stream/components/Comment/TopBar.spec.tsx index 2f33c6ab8..5ee691f70 100644 --- a/src/core/client/stream/components/Comment/TopBar.spec.tsx +++ b/src/core/client/stream/components/Comment/TopBar.spec.tsx @@ -1,12 +1,13 @@ import React from "react"; import TestRenderer from "react-test-renderer"; +import { PropTypesOf } from "talk-framework/types"; import { UIContext, UIContextProps } from "talk-ui/components"; import TopBar from "./TopBar"; it("renders correctly on small screens", () => { - const props = { + const props: PropTypesOf = { children:
Hello World
, }; @@ -25,7 +26,7 @@ it("renders correctly on small screens", () => { }); it("renders correctly on big screens", () => { - const props = { + const props: PropTypesOf = { children:
Hello World
, }; diff --git a/src/core/client/stream/components/Comment/Username.spec.tsx b/src/core/client/stream/components/Comment/Username.spec.tsx index 5092f5688..1a10e4012 100644 --- a/src/core/client/stream/components/Comment/Username.spec.tsx +++ b/src/core/client/stream/components/Comment/Username.spec.tsx @@ -1,12 +1,13 @@ import React from "react"; import TestRenderer from "react-test-renderer"; +import { PropTypesOf } from "talk-framework/types"; import { UIContext, UIContextProps } from "talk-ui/components"; import Username from "./Username"; it("renders correctly on small screens", () => { - const props = { + const props: PropTypesOf = { children: "Marvin", }; @@ -25,7 +26,7 @@ it("renders correctly on small screens", () => { }); it("renders correctly on big screens", () => { - const props = { + const props: PropTypesOf = { children: "Marvin", }; diff --git a/src/core/client/stream/components/Comment/__snapshots__/Comment.spec.tsx.snap b/src/core/client/stream/components/Comment/__snapshots__/Comment.spec.tsx.snap index eddab7d96..2d047c200 100644 --- a/src/core/client/stream/components/Comment/__snapshots__/Comment.spec.tsx.snap +++ b/src/core/client/stream/components/Comment/__snapshots__/Comment.spec.tsx.snap @@ -9,25 +9,7 @@ exports[`renders username and body 1`] = ` Marvin - 1995-12-17T06:24:00.000Z - - - - Woof - - -`; - -exports[`renders with gutterBottom 1`] = ` -
- - - Marvin - - - 1995-12-17T06:24:00.000Z + 1995-12-17T03:24:00.000Z diff --git a/src/core/client/stream/components/Comment/__snapshots__/Timestamp.spec.tsx.snap b/src/core/client/stream/components/Comment/__snapshots__/Timestamp.spec.tsx.snap new file mode 100644 index 000000000..862d6cad7 --- /dev/null +++ b/src/core/client/stream/components/Comment/__snapshots__/Timestamp.spec.tsx.snap @@ -0,0 +1,8 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders correctly 1`] = ` + +`; diff --git a/src/core/client/stream/components/Comment/__snapshots__/Username.spec.tsx.snap b/src/core/client/stream/components/Comment/__snapshots__/Username.spec.tsx.snap index 3836a45be..ab0e141e6 100644 --- a/src/core/client/stream/components/Comment/__snapshots__/Username.spec.tsx.snap +++ b/src/core/client/stream/components/Comment/__snapshots__/Username.spec.tsx.snap @@ -1,11 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`renders correctly 1`] = ` - -`; - exports[`renders correctly on big screens 1`] = ` { - const props: ReplyListProps = { + const props: PropTypesOf = { commentID: "comment-id", comments: [{ id: "comment-1" }, { id: "comment-2" }], onShowAll: noop, @@ -18,7 +20,7 @@ it("renders correctly", () => { }); describe("when there is more", () => { - const props: ReplyListProps = { + const props: PropTypesOf = { commentID: "comment-id", comments: [{ id: "comment-1" }, { id: "comment-2" }], onShowAll: sinon.spy(), diff --git a/src/core/client/stream/components/Stream.spec.tsx b/src/core/client/stream/components/Stream.spec.tsx index 05d30d66e..335f8fe27 100644 --- a/src/core/client/stream/components/Stream.spec.tsx +++ b/src/core/client/stream/components/Stream.spec.tsx @@ -1,12 +1,14 @@ import { shallow } from "enzyme"; import { noop } from "lodash"; import React from "react"; -import sinon from "sinon"; +import sinon, { SinonSpy } from "sinon"; -import Stream, { StreamProps } from "./Stream"; +import { PropTypesOf } from "talk-framework/types"; + +import Stream from "./Stream"; it("renders correctly", () => { - const props: StreamProps = { + const props: PropTypesOf = { assetID: "asset-id", isClosed: false, comments: [{ id: "comment-1" }, { id: "comment-2" }], @@ -19,7 +21,7 @@ it("renders correctly", () => { }); describe("when there is more", () => { - const props = { + const props: PropTypesOf = { assetID: "asset-id", isClosed: false, comments: [{ id: "comment-1" }, { id: "comment-2" }], @@ -35,7 +37,7 @@ describe("when there is more", () => { it("calls onLoadMore", () => { wrapper.find("#talk-comments-stream-loadMore").simulate("click"); - expect(props.onLoadMore.calledOnce).toBe(true); + expect((props.onLoadMore as SinonSpy).calledOnce).toBe(true); }); const wrapperDisabledButton = shallow(); diff --git a/src/core/client/stream/containers/CommentContainer.spec.tsx b/src/core/client/stream/containers/CommentContainer.spec.tsx index 184d6454c..98612be38 100644 --- a/src/core/client/stream/containers/CommentContainer.spec.tsx +++ b/src/core/client/stream/containers/CommentContainer.spec.tsx @@ -1,16 +1,18 @@ import { shallow } from "enzyme"; import React from "react"; +import { PropTypesOf } from "talk-framework/types"; + import { CommentContainer } from "./CommentContainer"; it("renders username and body", () => { - const props = { + const props: PropTypesOf = { data: { author: { username: "Marvin", }, body: "Woof", - createdAt: new Date("December 17, 1995 03:24:00").toISOString(), + createdAt: "1995-12-17T03:24:00.000Z", }, }; diff --git a/src/core/client/stream/containers/ReplyListContainer.spec.tsx b/src/core/client/stream/containers/ReplyListContainer.spec.tsx index 75cb129ca..3a414dd51 100644 --- a/src/core/client/stream/containers/ReplyListContainer.spec.tsx +++ b/src/core/client/stream/containers/ReplyListContainer.spec.tsx @@ -8,7 +8,7 @@ import ReplyList from "../components/ReplyList"; import { ReplyListContainer } from "./ReplyListContainer"; it("renders correctly", () => { - const props: any = { + const props: PropTypesOf = { comment: { id: "comment-id", replies: { @@ -18,14 +18,14 @@ it("renders correctly", () => { relay: { hasMore: noop, isLoading: noop, - }, + } as any, }; const wrapper = shallow(); expect(wrapper).toMatchSnapshot(); }); it("renders correctly when replies are null", () => { - const props: any = { + const props: PropTypesOf = { comment: { id: "comment-id", replies: null, @@ -33,7 +33,7 @@ it("renders correctly when replies are null", () => { relay: { hasMore: noop, isLoading: noop, - }, + } as any, }; const wrapper = shallow(); expect(wrapper).toMatchSnapshot(); diff --git a/src/core/client/stream/containers/__snapshots__/CommentContainer.spec.tsx.snap b/src/core/client/stream/containers/__snapshots__/CommentContainer.spec.tsx.snap index af2754b54..9e2476f37 100644 --- a/src/core/client/stream/containers/__snapshots__/CommentContainer.spec.tsx.snap +++ b/src/core/client/stream/containers/__snapshots__/CommentContainer.spec.tsx.snap @@ -8,6 +8,6 @@ exports[`renders username and body 1`] = ` } } body="Woof" - createdAt="1995-12-17T06:24:00.000Z" + createdAt="1995-12-17T03:24:00.000Z" /> `; diff --git a/src/core/client/stream/test/__snapshots__/loadMore.spec.tsx.snap b/src/core/client/stream/test/__snapshots__/loadMore.spec.tsx.snap index 2ba780577..b3d193c41 100644 --- a/src/core/client/stream/test/__snapshots__/loadMore.spec.tsx.snap +++ b/src/core/client/stream/test/__snapshots__/loadMore.spec.tsx.snap @@ -60,10 +60,10 @@ exports[`loads more comments 1`] = `

{ const props = { - date: new Date("December 17, 2108 03:24:00").toISOString(), + date: "2018-12-17T03:24:00", }; const tree = create().toJSON(); @@ -17,8 +19,8 @@ it("uses formatter from context", () => { const context: any = { timeagoFormatter: () => "My Context Formatter", }; - const props = { - date: new Date("December 17, 2108 03:24:00").toISOString(), + const props: PropTypesOf = { + date: "2018-12-17T03:24:00.000Z", }; const tree = create( @@ -31,7 +33,7 @@ it("uses formatter from context", () => { it("uses formatter from props", () => { const props = { - date: new Date("December 17, 2108 03:24:00").toISOString(), + date: "2018-12-17T03:24:00.000Z", formatter: () => "My Props Formatter", }; const tree = create().toJSON(); diff --git a/src/core/client/ui/components/RelativeTime/__snapshots__/RelativeTime.spec.tsx.snap b/src/core/client/ui/components/RelativeTime/__snapshots__/RelativeTime.spec.tsx.snap index 3f2d9c893..0460b4b56 100644 --- a/src/core/client/ui/components/RelativeTime/__snapshots__/RelativeTime.spec.tsx.snap +++ b/src/core/client/ui/components/RelativeTime/__snapshots__/RelativeTime.spec.tsx.snap @@ -3,18 +3,18 @@ exports[`uses default formatter 1`] = ` `; exports[`uses formatter from context 1`] = ` @@ -23,8 +23,8 @@ exports[`uses formatter from context 1`] = ` exports[`uses formatter from props 1`] = `