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>
This commit is contained in:
co-authored by
Rotimi Best
parent
4b2e58b1de
commit
6d689ede45
@@ -0,0 +1,17 @@
|
||||
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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user