Files
classroomio/apps/dashboard/src/lib/utils/functions/generateSlug.spec.js
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

18 lines
648 B
JavaScript

import generateSlug from './generateSlug';
describe('generateSlug', () => {
test('should return a string with lowercase letters and hyphens when given a valid title', () => {
const title = 'This is a Valid Title';
const expected = 'this-is-a-valid-title' + `-${new Date().getTime()}`;
const result = generateSlug(title);
expect(result).toBe(expected);
});
test('should include the current timestamp at the end of the string', () => {
const title = 'This is a Valid Title';
const result = generateSlug(title);
const timestamp = result.split('-').pop();
expect(Number(timestamp)).toBeGreaterThan(0);
});
});