File: test/tests_events.js

Recommend this page to a friend!
  Classes of Arturs Sosins   Countly SDK for Node.js   test/tests_events.js   Download  
File: test/tests_events.js
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Countly SDK for Node.js
Report events to be tracked with by Count.ly API
Author: By
Last change: Refactoring Test Objects
test refactor
Date: 1 month ago
Size: 1,398 bytes
 

Contents

Class file image Download
/* eslint-disable no-console */ var Countly = require("../lib/countly"); var hp = require("./helpers/helper_functions"); var testUtils = require("./helpers/test_utils"); // init function function initMain() { Countly.init({ app_key: "YOUR_APP_KEY", url: "https://try.count.ly", interval: 10000, max_events: -1, }); } describe("Events tests", () => { beforeEach(async() => { await hp.clearStorage(); }); it("Record and check custom event", (done) => { // initialize SDK initMain(); // send custom event Countly.add_event(testUtils.getEventObj()); // read event queue setTimeout(() => { var event = hp.readEventQueue()[0]; hp.eventValidator(testUtils.getEventObj(), event); done(); }, hp.mWait); }); it("Record and check timed events", (done) => { // initialize SDK initMain(); // send timed event Countly.start_event("timed"); setTimeout(() => { Countly.end_event(testUtils.getTimedEventObj()); // read event queue setTimeout(() => { var event = hp.readEventQueue()[0]; hp.eventValidator(testUtils.getTimedEventObj(), event, (hp.mWait / 1000)); done(); }, hp.sWait); }, hp.mWait); }); });