1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

fix react-ga initialization

This commit is contained in:
Matthias Kretschmann 2019-05-16 11:39:25 +02:00
parent d49cace56a
commit 7d64ec2d55
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 8 additions and 5 deletions

View File

@ -3,15 +3,15 @@ import ReactGA, { FieldsObject } from 'react-ga'
import { RouteComponentProps } from 'react-router-dom' import { RouteComponentProps } from 'react-router-dom'
import { analyticsId } from '../config' import { analyticsId } from '../config'
const withTracker = <P extends RouteComponentProps>(
WrappedComponent: any,
options: FieldsObject = {}
) => {
ReactGA.initialize(analyticsId, { ReactGA.initialize(analyticsId, {
testMode: process.env.NODE_ENV === 'test', testMode: process.env.NODE_ENV === 'test',
debug: false debug: false
}) })
const withTracker = <P extends RouteComponentProps>(
WrappedComponent: any,
options: FieldsObject = {}
) => {
const trackPage = (page: string) => { const trackPage = (page: string) => {
options.isWeb3 = window.web3 !== undefined options.isWeb3 = window.web3 !== undefined

View File

@ -4,6 +4,7 @@ import React from 'react'
import { render, fireEvent } from 'react-testing-library' import { render, fireEvent } from 'react-testing-library'
import { DDO } from '@oceanprotocol/squid' import { DDO } from '@oceanprotocol/squid'
import { StateMock } from '@react-mock/state' import { StateMock } from '@react-mock/state'
import ReactGA from 'react-ga'
import { User } from '../../context' import { User } from '../../context'
import AssetFile from './AssetFile' import AssetFile from './AssetFile'
@ -31,6 +32,8 @@ const contextConnectedMock = {
message: '' message: ''
} }
ReactGA.initialize('foo', { testMode: true })
describe('AssetFile', () => { describe('AssetFile', () => {
it('renders without crashing', () => { it('renders without crashing', () => {
const { container } = render(<AssetFile file={file} ddo={ddo} />) const { container } = render(<AssetFile file={file} ddo={ddo} />)