Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import React from 'react'
import { GraphQLTaggedNode, Variables } from 'relay-runtime'
import { QueryRenderer } from 'react-relay'
import hoistStatics from 'hoist-non-react-statics'
import { createMockEnvironment } from 'relay-test-utils'
import { Environment } from '.'
interface Config {
query?: GraphQLTaggedNode
queriesParams?: (props: Object) => Object
variables?: Variables
hideSplash?: boolean
}
export const env = createMockEnvironment()
export default function createQueryRenderer(
FragmentComponent: React.ComponentType,
Component: React.ComponentType,
config: Config,
LoadingComponent?: React.ComponentType
) {
const { query, queriesParams } = config
function QueryRendererWrapper(props: Object) {
const variables = (queriesParams ? queriesParams(props) : config.variables) as Variables
return (
jest.mock("lib/relay/createEnvironment", () => ({
defaultEnvironment: require("relay-test-utils").createMockEnvironment(),
}))
jest.mock("lib/relay/createEnvironment", () => ({
defaultEnvironment: require("relay-test-utils").createMockEnvironment(),
}))
beforeEach(() => {
environment = createMockEnvironment()
;(useTracking as jest.Mock).mockImplementation(() => {
return {
trackEvent,
}
})
})