From 6b77c3ac240febfa2220f2a53f099727e07410d6 Mon Sep 17 00:00:00 2001 From: "alexander.svendsen" Date: Wed, 9 Jan 2019 12:01:41 +0100 Subject: [PATCH] Gtag func is undefined in tests suits Fix it so the test can run without it defined --- src/Game.test.tsx | 2 -- src/scenario/main.ts | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Game.test.tsx b/src/Game.test.tsx index 613024f..dbaebaa 100644 --- a/src/Game.test.tsx +++ b/src/Game.test.tsx @@ -1,8 +1,6 @@ import * as React from 'react'; import * as ReactDOM from 'react-dom'; -(global as any).gtag = () => undefined; - import Game from './Game'; (window as any).HTMLElement.prototype.scrollIntoView = () => undefined; diff --git a/src/scenario/main.ts b/src/scenario/main.ts index 2d0d7d4..0b796d0 100644 --- a/src/scenario/main.ts +++ b/src/scenario/main.ts @@ -30,9 +30,9 @@ function timeDiffInSeconds(): number { return Math.floor((new Date().getTime() - startTime.getTime()) / 1000); } -const gtag = (global as any).gtag as any; +const gtag: (a: any, b:any, c:any) => void = (global as any).gtag; const tagIt = (action: string) => - gtag('event', action, { + !!gtag && gtag('event', action, { event_category: 'game', event_label: new Date().toUTCString(), value: timeDiffInSeconds(),