Files
classroomio/apps/dashboard/src/lib/utils/functions/generateUUID.spec.ts
T
Toyin MuhammedandRotimi Best 6d689ede45 feat: unit tests for utils (#92)
* init

* get unit test working for course.ts file

* added some other tests

* tests halfway + change config to accomodate js files

* utility functions tests done

* fix: config file + miscellaneous fixes

* fix: prepare script

* fix lock file

---------

Co-authored-by: Rotimi Best <best@classroomio.com>
2023-12-20 14:28:40 +03:00

27 lines
790 B
TypeScript

import generateUUID from './generateUUID';
import { isUUID } from './isUUID';
// This test suite tests both the generateUUID and isUUID functions
describe('GenerateUUID', () => {
test('should be true when tested with the uuid function', () => {
const result = generateUUID();
expect(isUUID(result)).toBe(true);
});
test('should generate unique UUIDs each time', () => {
const uuid1 = generateUUID();
const uuid2 = generateUUID();
expect(uuid1).not.toBe(uuid2);
});
test('should return true for a valid UUID', () => {
const uuid = '123e4567-e89b-12d3-a456-426614174000';
expect(isUUID(uuid)).toBe(true);
});
test('should return false for an invalid UUID', () => {
const uuid = 'invalid-uuid';
expect(isUUID(uuid)).toBe(false);
});
});