File: test/tests_views.js

Recommend this page to a friend!
  Classes of Arturs Sosins   Countly SDK for Node.js   test/tests_views.js   Download  
File: test/tests_views.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: test refactor
Date: 1 month ago
Size: 2,432 bytes
 

Contents

Class file image Download
/* eslint-disable no-console */ var Countly = require("../lib/countly"); var hp = require("./helpers/helper_functions"); var pageNameOne = "test view page name1"; var pageNameTwo = "test view page name2"; // init function function initMain() { Countly.init({ app_key: "YOUR_APP_KEY", url: "https://try.count.ly", interval: 10000, max_events: -1, }); } describe("View test", () => { beforeEach(async() => { await hp.clearStorage(); }); it("Record and validate page views", (done) => { // initialize SDK initMain(); // send track view Countly.track_view(pageNameOne); // read event queue setTimeout(() => { var event = hp.readEventQueue()[0]; hp.viewEventValidator(pageNameOne, event); done(); }, hp.sWait); }); it("Record and validate timed page views with same name", (done) => { // initialize SDK initMain(); Countly.track_view(pageNameOne); setTimeout(() => { // send track view Countly.track_view(pageNameOne); // read event queue setTimeout(() => { var event = hp.readEventQueue(); // start view hp.viewEventValidator(pageNameOne, event[0]); // end view with recording duration hp.viewEventValidator(pageNameOne, event[1], (hp.mWait / 1000)); // start second view hp.viewEventValidator(pageNameOne, event[2]); done(); }, hp.sWait); }, hp.mWait); }); it("Record and validate timed page views with same name", (done) => { // initialize SDK initMain(); Countly.track_view(pageNameOne); setTimeout(() => { // send track view Countly.track_view(pageNameTwo); // read event queue setTimeout(() => { var event = hp.readEventQueue(); // start view hp.viewEventValidator(pageNameOne, event[0]); // end view with recording duration hp.viewEventValidator(pageNameOne, event[1], (hp.mWait / 1000)); // start second view hp.viewEventValidator(pageNameTwo, event[2]); done(); }, hp.sWait); }, hp.mWait); }); });