import sinon from "sinon" ; import { waitForElement , within } from "coral-framework/testHelpers" ; import { settings , stories } from "../../fixtures" ; import create from "./create" ; const story = stories [ 2 ] ; async function createTestRenderer ( resolver = { } , options = { } ) { const resolvers = { ... resolver , Query : { settings : sinon . stub ( ) . returns ( settings ) , stream : sinon . stub ( ) . callsFake ( ( _ , variables ) => { expectAndFail ( variables . id ) . toBe ( story . id ) ; return story ; } ) , ... resolver . Query , } , } ; const { testRenderer , context } = create ( { logNetwork : false , muteNetworkErrors : options . muteNetworkErrors , resolvers , initLocalState : ( localRecord ) => { localRecord . setValue ( story . id , "storyID" ) ; } , } ) ; return { testRenderer , context , } ; } it ( "renders comment stream" , async ( ) => { const { testRenderer } = await createTestRenderer ( ) ; await waitForElement ( ( ) => within ( testRenderer . root ) . getByTestID ( "comments-allComments-log" ) ) ; expect ( within ( testRenderer . root ) . toJSON ( ) ) . toMatchSnapshot ( ) ; } ) ;