1 import generateUID from './generateUID';
3 describe('generateUID', () => {
4 it('should generate unique IDs with a prefix', () => {
6 const id1 = generateUID(prefix);
7 const id2 = generateUID(prefix);
9 expect(id1).toMatch(new RegExp(`^${prefix}-\\d+$`));
10 expect(id2).toMatch(new RegExp(`^${prefix}-\\d+$`));
11 expect(id1).not.toBe(id2);
14 it('should generate unique IDs without a prefix', () => {
15 const id1 = generateUID();
16 const id2 = generateUID();
18 expect(id1).toMatch(/^id-\d+$/);
19 expect(id2).toMatch(/^id-\d+$/);
20 expect(id1).not.toBe(id2);