|
1 | | -import { cliux, validatePath, getBranchFromAlias } from '../../lib'; |
| 1 | +import { cliux, validatePath, getBranchFromAlias, generateUid, generateShortUid } from '../../lib'; |
2 | 2 | import { expect } from 'chai'; |
3 | 3 | import { fancy } from 'fancy-test'; |
4 | 4 |
|
@@ -246,3 +246,32 @@ describe('Testing the getBranchFromAlias function', () => { |
246 | 246 | }); |
247 | 247 | }); |
248 | 248 | }); |
| 249 | + |
| 250 | +describe('generateUid', () => { |
| 251 | + it('should return a string', () => { |
| 252 | + expect(generateUid()).to.be.a('string'); |
| 253 | + }); |
| 254 | + |
| 255 | + it('should return a valid UUID v4 format', () => { |
| 256 | + const uuidV4Regex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i; |
| 257 | + expect(generateUid()).to.match(uuidV4Regex); |
| 258 | + }); |
| 259 | + |
| 260 | + it('should return a unique value on each call', () => { |
| 261 | + expect(generateUid()).to.not.equal(generateUid()); |
| 262 | + }); |
| 263 | +}); |
| 264 | + |
| 265 | +describe('generateShortUid', () => { |
| 266 | + it('should return a string', () => { |
| 267 | + expect(generateShortUid()).to.be.a('string'); |
| 268 | + }); |
| 269 | + |
| 270 | + it('should return a non-empty string', () => { |
| 271 | + expect(generateShortUid().length).to.be.greaterThan(0); |
| 272 | + }); |
| 273 | + |
| 274 | + it('should return a unique value on each call', () => { |
| 275 | + expect(generateShortUid()).to.not.equal(generateShortUid()); |
| 276 | + }); |
| 277 | +}); |
0 commit comments