From 3b306e589506e9a1fe3665ae1884c56b5bab7e68 Mon Sep 17 00:00:00 2001 From: Xymorot Date: Sat, 12 Oct 2019 21:05:19 +0200 Subject: [PATCH] test: add test suite for uuid service --- tests/services/uuid.spec.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/services/uuid.spec.ts diff --git a/tests/services/uuid.spec.ts b/tests/services/uuid.spec.ts new file mode 100644 index 0000000..7be4356 --- /dev/null +++ b/tests/services/uuid.spec.ts @@ -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'); + }); +});