test: add test suite for uuid service

This commit is contained in:
Xymorot 2019-10-12 21:05:19 +02:00
parent b72e608280
commit 3b306e5895
1 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,18 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';
import { uuid } from '../../src/services/uuid';
describe('UUID Service', function() {
this.timeout(1000);
it('provides universal unique identifiers', () => {
const uuid1 = uuid();
expect(uuid1).to.match(
/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i,
'generated uuid does not match the UUID format'
);
const uuid2 = uuid();
const uuid3 = uuid();
expect(uuid2).to.not.equal(uuid3, 'generated uuids are not unique');
});
});