File: test/tests_sessions.js

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

Contents

Class file image Download
/* eslint-disable no-console */
var Countly = require("../lib/countly");
var hp = require("./helpers/helper_functions");

// init function
function initMain() {
    Countly.init({
        app_key: "YOUR_APP_KEY",
        url: "https://try.count.ly",
        max_events: -1,
    });
}
describe("Sessions tests", () => {
    it("Start session and validate the request queue", (done) => {
        // clear previous data
        hp.clearStorage();
        // initialize SDK
        initMain();
        // send session calls
        Countly.begin_session();
        setTimeout(() => {
            var beg = hp.readRequestQueue()[0];
            hp.sessionRequestValidator(beg);
            done();
        }, hp.sWait);
    });
    it("Start and end session and validate the request queue", (done) => {
        // clear previous data
        hp.clearStorage();
        // initialize SDK
        initMain();
        // send session calls
        Countly.begin_session();
        setTimeout(() => {
            Countly.end_session();
            setTimeout(() => {
                var beg = hp.readRequestQueue()[0];
                var end = hp.readRequestQueue()[1];
                hp.sessionRequestValidator(beg, end, (hp.mWait / 1000));
                done();
            }, hp.sWait);
        }, hp.mWait);
    });
});