From 11de453aacdba799c90ab6201cdfda85f4a61c3c Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Mon, 9 Jul 2018 17:41:39 -0300 Subject: [PATCH] Fix showAllReplies test --- .../showAllReplies.spec.tsx.snap | 22 +++--- .../stream/test/showAllReplies.spec.tsx | 71 ++++++++++--------- 2 files changed, 50 insertions(+), 43 deletions(-) diff --git a/src/core/client/stream/test/__snapshots__/showAllReplies.spec.tsx.snap b/src/core/client/stream/test/__snapshots__/showAllReplies.spec.tsx.snap index b9acbb5cd..ced8cfb6a 100644 --- a/src/core/client/stream/test/__snapshots__/showAllReplies.spec.tsx.snap +++ b/src/core/client/stream/test/__snapshots__/showAllReplies.spec.tsx.snap @@ -164,16 +164,20 @@ exports[`show all replies 1`] = ` What's up?

- +

+ Isabelle +

+

+ Hey! +

+ diff --git a/src/core/client/stream/test/showAllReplies.spec.tsx b/src/core/client/stream/test/showAllReplies.spec.tsx index 98501d7dc..df7ac1ebb 100644 --- a/src/core/client/stream/test/showAllReplies.spec.tsx +++ b/src/core/client/stream/test/showAllReplies.spec.tsx @@ -10,6 +10,40 @@ import AppQuery from "talk-stream/queries/AppQuery"; import createEnvironment from "./createEnvironment"; import { assets, comments } from "./fixtures"; +const commentStub = { + ...comments[0], + replies: { + edges: sinon + .stub() + .onFirstCall() + .returns([ + { + node: comments[1], + cursor: comments[1].createdAt, + }, + ]) + .onSecondCall() + .returns([ + { + node: comments[2], + cursor: comments[2].createdAt, + }, + ]), + pageInfo: sinon + .stub() + .onFirstCall() + .returns({ + endCursor: comments[1].createdAt, + hasNextPage: true, + }) + .onSecondCall() + .returns({ + endCursor: comments[2].createdAt, + hasNextPage: false, + }), + }, +}; + const assetStub = { ...assets[0], comments: { @@ -18,40 +52,8 @@ const assetStub = { }, edges: [ { - node: { - ...comments[0], - replies: { - edges: sinon - .stub() - .onFirstCall() - .returns([ - { - node: comments[1], - cursor: comments[1].createdAt, - }, - ]) - .onSecondCall() - .returns([ - { - node: comments[2], - cursor: comments[2].createdAt, - }, - ]), - pageInfo: sinon - .stub() - .onFirstCall() - .returns({ - endCursor: comments[1].createdAt, - hasNextPage: true, - }) - .onSecondCall() - .returns({ - endCursor: comments[2].createdAt, - hasNextPage: false, - }), - }, - }, - cursor: comments[0].createdAt, + node: commentStub, + cursor: commentStub.createdAt, }, ], }, @@ -59,6 +61,7 @@ const assetStub = { const resolvers = { Query: { + comment: () => commentStub, asset: () => assetStub, }, };