mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-29 18:06:01 +08:00
React-GA typing files (#9397)
This commit is contained in:
53
react-ga/react-ga-tests.tsx
Normal file
53
react-ga/react-ga-tests.tsx
Normal file
@@ -0,0 +1,53 @@
|
||||
/// <reference path="react-ga.d.ts" />
|
||||
/// <reference path="../jasmine/jasmine.d.ts" />
|
||||
|
||||
describe("Testing react-ga initialize object", () => {
|
||||
it("Able to initialize react-ga object", () => {
|
||||
let ga = __reactGA;
|
||||
ga.initialize("UA-65432-1");
|
||||
});
|
||||
it("Able to initailize react-ga object", () => {
|
||||
let ga = __reactGA;
|
||||
|
||||
let options: __reactGA.InitializeOptions = {
|
||||
debug: true,
|
||||
}
|
||||
|
||||
ga.initialize("UA-65432-1", options);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Testing react-ga pageview calls", () => {
|
||||
it("Able to make pageview calls", () => {
|
||||
let ga = __reactGA;
|
||||
ga.initialize("UA-65432-1");
|
||||
|
||||
ga.pageview("http://telshin.com");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Testing react-ga modal calls", () => {
|
||||
it("Able to make modal calls", () => {
|
||||
let ga = __reactGA;
|
||||
ga.initialize("UA-65432-1");
|
||||
|
||||
ga.modalview("Test modal");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Testing react-ga event calls", () => {
|
||||
it("Able to make event calls", () => {
|
||||
let ga = __reactGA;
|
||||
ga.initialize("UA-65432-1");
|
||||
|
||||
let options: __reactGA.EventArgs = {
|
||||
category: "Test",
|
||||
action: "CI",
|
||||
label: "Running Jasmine tests for react-ga typscript library",
|
||||
value: 4,
|
||||
nonInteraction: true,
|
||||
}
|
||||
|
||||
ga.event(options);
|
||||
});
|
||||
});
|
||||
27
react-ga/react-ga.d.ts
vendored
Normal file
27
react-ga/react-ga.d.ts
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
// Type definitions for react-fa v1.4.1
|
||||
// Project: https://github.com/react-ga/react-ga
|
||||
// Definitions by: Tim Aldridge <https://github.com/telshin>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace __reactGA {
|
||||
export interface EventArgs {
|
||||
category: string;
|
||||
action: string;
|
||||
label?: string;
|
||||
value?: number;
|
||||
nonInteraction?: boolean;
|
||||
}
|
||||
|
||||
export interface InitializeOptions {
|
||||
debug?: boolean;
|
||||
}
|
||||
|
||||
export function initialize(trackingCode: string, options?: InitializeOptions): void;
|
||||
export function pageview(path: string): void;
|
||||
export function modalview(name: string): void;
|
||||
export function event(args: EventArgs): void;
|
||||
}
|
||||
|
||||
declare module 'react-ga' {
|
||||
export = __reactGA;
|
||||
}
|
||||
Reference in New Issue
Block a user