File size: 698 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import generateId from '../../logic/generateId';
describe('generateId', () => {
it('should generate a unique id', () => {
expect(/\w{8}-\w{4}-4\w{3}-\w{4}-\w{12}/i.test(generateId())).toBeTruthy();
});
it('should fallback to performance if crypto is undefined', () => {
Object.defineProperty(window, 'crypto', {
value: undefined,
});
expect(/\w{8}-\w{4}-4\w{3}-\w{4}-\w{12}/i.test(generateId())).toBeTruthy();
});
it('should fallback to current date if performance is undefined', () => {
Object.defineProperty(window, 'performance', {
value: undefined,
});
expect(/\w{8}-\w{4}-4\w{3}-\w{4}-\w{12}/i.test(generateId())).toBeTruthy();
});
});
|