clarity-decode
Version:
An analytics library that uses web page interactions to generate aggregated insights
36 lines (31 loc) • 2.17 kB
JavaScript
const { assert } = require('chai');
const { decode } = require('../build/clarity.decode.js');
describe('decode function', () => {
it('should decode a simple payload', () => {
// This is a very simple test that focuses on basic decoding functionality
const testPayload = {
e: ["0.8.20", 1, 0, 506, "devtools", "1mtqiaz", "1c27tix", 2, 0, 0, 0, "https://test.com/"],
a: [
[],
[],
[],
[],
[],
[],
[],
[], 1, ["https://test.com/"], 3, ["A little bit of this and that!"], 4, ["test.com"], 5, ["BlogPosting"], 9, ["en-US"], 15, ["1xtxvl0"], 17, ["ltr"], 18, ["Story 8", "Story 7", "Story 6"], 20, ["A title!"], 21, ["blogger"], 22, ["macOS"], 23, ["15.5.0"], 24, ["undefined~8", "undefined~138"], 26, ["1.7999999523162842"], 27, ["4g"], 28, ["1979"], 29, ["2"], 31, ["44nejbc7s.6933hhug7"], 32, ["519i394pb.53uwavtzg"], 34, ["America/Los_Angeles"], 35, ["420"], 36, ["1"], 37, ["-1"]],
[],
[],
[]
],
};
const input = JSON.stringify(testPayload);
const result = decode(input);
assert.isObject(result);
assert.isNumber(result.timestamp);
assert.isObject(result.envelope);
assert.equal(result.envelope.version, "0.8.20");
assert.equal(result.contextMenu[0].data.target, 488);
assert.equal(result.contextMenu[0].data.button, 2);
});
});