UNPKG

@aller/blink

Version:

A library for tracking user behaviour.

51 lines (42 loc) 1.5 kB
import generateUUID from '../uuid'; describe('generateUUID', () => { it('is not conistent when given no key', () => { const uuid = generateUUID(); expect(generateUUID()).not.toBe(uuid); }); it('UUID is 36 char long', () => { const uuid = generateUUID(); expect(uuid.length).toBe(36); }); it('is a string', () => { const uuid = generateUUID(); expect(typeof uuid).toBe('string'); }); it('is consistent when given a domain key', () => { const uuid = generateUUID('pageView'); expect(generateUUID('pageView')).toBe(uuid); }); it('is 36 chars long when given a domain key', () => { const uuid = generateUUID('someDomain'); expect(uuid.length).toBe(36); }); it('is a string when given a domain key', () => { const uuid = generateUUID('xavierId'); expect(typeof uuid).toBe('string'); }); it('is not the same as uuid in other domain', () => { const firstUuid = generateUUID('xavierId'); const secondUuid = generateUUID('pageView'); expect(firstUuid).not.toBe(secondUuid); }); it('is consistent in domain regardless of call order', () => { const firstUuid = generateUUID('xavierId'); const secondUuid = generateUUID('pageView'); const thirdUuid = generateUUID('pageView'); const fourthUuid = generateUUID('xavierId'); expect(firstUuid).toBe(fourthUuid); expect(secondUuid).toBe(thirdUuid); expect(firstUuid).not.toBe(secondUuid); expect(thirdUuid).not.toBe(fourthUuid); }); });