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:
Toyin Muhammed
2023-12-20 14:28:40 +03:00
committed by GitHub
co-authored by Rotimi Best
parent 4b2e58b1de
commit 6d689ede45
24 changed files with 2293 additions and 35 deletions
@@ -0,0 +1,38 @@
import { removeDuplicate } from './removeDuplicate';
describe('removeDuplicate', () => {
test('should remove duplicate elements of an array', () => {
const result = removeDuplicate([1, 1, 2, 3, 3, 4, 5]);
const expected = [1, 2, 3, 4, 5];
expect(result).toStrictEqual(expected);
expect(result.length).toBe(5);
});
test('should return an empty array', () => {
const result = removeDuplicate([]);
const expected = [];
expect(result).toStrictEqual(expected);
expect(result.length).toBe(0);
});
test('should return an array with the same element', () => {
const result = removeDuplicate([1]);
const expected = [1];
expect(result).toStrictEqual(expected);
expect(result.length).toBe(1);
});
test('should return an array with only one element', () => {
const result = removeDuplicate([1, 1, 1, 1]);
const expected = [1];
expect(result).toStrictEqual(expected);
expect(result.length).toBe(1);
});
test('should return an array with the unique elements in the same order as the original array', () => {
const result = removeDuplicate([1, 2, 3, 4, 5, 1, 2, 3, 4, 5]);
const expected = [1, 2, 3, 4, 5];
expect(result).toStrictEqual(expected);
expect(result.length).toBe(5);
});
});