avo-inspector
Version:
[](https://badge.fury.io/js/avo-inspector)
41 lines (40 loc) • 1.74 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var AvoInstallationId_1 = require("../AvoInstallationId");
var AvoStorage_1 = require("../AvoStorage");
var AvoInspector_1 = require("../AvoInspector");
var constants_1 = require("../__tests__/constants");
describe("InstallationId", function () {
var storage = new AvoStorage_1.AvoStorage(constants_1.defaultOptions.shouldLog);
beforeAll(function () {
new AvoInspector_1.AvoInspector(constants_1.defaultOptions);
});
test("cacheKey equal to \"AvoInstallationId\"", function () {
expect(AvoInstallationId_1.AvoInstallationId.cacheKey).toEqual("AvoInstallationId");
});
test("Sets installationId on AvoInspector init", function () {
// Given
// When
var installationId = AvoInstallationId_1.AvoInstallationId.getInstallationId();
// Then
expect(installationId).not.toBeNull();
});
test("Creates installation id if not present", function () {
// Given
storage.removeItem(AvoInstallationId_1.AvoInstallationId.cacheKey);
// When
var installationId = AvoInstallationId_1.AvoInstallationId.getInstallationId();
// Then
expect(installationId).not.toBeNull();
});
test("Reuses installation id if present", function () {
// Given
var newId = "test-installation-id";
storage.setItem(AvoInstallationId_1.AvoInstallationId.cacheKey, "test-installation-id");
AvoInstallationId_1.AvoInstallationId.installationId = null;
// When
var installationId = AvoInstallationId_1.AvoInstallationId.getInstallationId();
// Then
expect(installationId).toBe(newId);
});
});