UNPKG

@aller/blink

Version:

A library for tracking user behaviour.

48 lines 1.94 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var uuid_1 = __importDefault(require("../uuid")); describe('generateUUID', function () { it('is not conistent when given no key', function () { var uuid = uuid_1.default(); expect(uuid_1.default()).not.toBe(uuid); }); it('UUID is 36 char long', function () { var uuid = uuid_1.default(); expect(uuid.length).toBe(36); }); it('is a string', function () { var uuid = uuid_1.default(); expect(typeof uuid).toBe('string'); }); it('is consistent when given a domain key', function () { var uuid = uuid_1.default('pageView'); expect(uuid_1.default('pageView')).toBe(uuid); }); it('is 36 chars long when given a domain key', function () { var uuid = uuid_1.default('someDomain'); expect(uuid.length).toBe(36); }); it('is a string when given a domain key', function () { var uuid = uuid_1.default('xavierId'); expect(typeof uuid).toBe('string'); }); it('is not the same as uuid in other domain', function () { var firstUuid = uuid_1.default('xavierId'); var secondUuid = uuid_1.default('pageView'); expect(firstUuid).not.toBe(secondUuid); }); it('is consistent in domain regardless of call order', function () { var firstUuid = uuid_1.default('xavierId'); var secondUuid = uuid_1.default('pageView'); var thirdUuid = uuid_1.default('pageView'); var fourthUuid = uuid_1.default('xavierId'); expect(firstUuid).toBe(fourthUuid); expect(secondUuid).toBe(thirdUuid); expect(firstUuid).not.toBe(secondUuid); expect(thirdUuid).not.toBe(fourthUuid); }); }); //# sourceMappingURL=uuid.test.js.map