-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
Signed-off-by: Amit Amrutiya <[email protected]>
- Loading branch information
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import convertSecondsToDuration from "../../utils/secToDuration"; | ||
Check failure on line 1 in backend/test/utils/secToDuration.test.js GitHub Actions / build
|
||
|
||
describe("convertSecondsToDuration", () => { | ||
Check failure on line 3 in backend/test/utils/secToDuration.test.js GitHub Actions / build
|
||
it("should correctly convert seconds to hours and minutes", () => { | ||
Check failure on line 4 in backend/test/utils/secToDuration.test.js GitHub Actions / build
|
||
expect(convertSecondsToDuration(3661)).toBe("1h 1m"); | ||
Check failure on line 5 in backend/test/utils/secToDuration.test.js GitHub Actions / build
Check failure on line 5 in backend/test/utils/secToDuration.test.js GitHub Actions / build
Check failure on line 5 in backend/test/utils/secToDuration.test.js GitHub Actions / build
|
||
}); | ||
Check failure on line 6 in backend/test/utils/secToDuration.test.js GitHub Actions / build
|
||
|
||
it("should correctly convert seconds to minutes and seconds", () => { | ||
Check failure on line 8 in backend/test/utils/secToDuration.test.js GitHub Actions / build
|
||
expect(convertSecondsToDuration(61)).toBe("1m 1s"); | ||
Check failure on line 9 in backend/test/utils/secToDuration.test.js GitHub Actions / build
Check failure on line 9 in backend/test/utils/secToDuration.test.js GitHub Actions / build
Check failure on line 9 in backend/test/utils/secToDuration.test.js GitHub Actions / build
|
||
}); | ||
Check failure on line 10 in backend/test/utils/secToDuration.test.js GitHub Actions / build
|
||
|
||
it("should correctly convert seconds to seconds", () => { | ||
expect(convertSecondsToDuration(1)).toBe("1s"); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import GetAvgRating from "../../utils/avgRating"; | ||
|
||
describe("GetAvgRating", () => { | ||
it("should return 0 when the array is empty", () => { | ||
expect(GetAvgRating([])).toBe(0); | ||
}); | ||
|
||
it("should correctly calculate the average rating", () => { | ||
const ratings = [ | ||
{ rating: 5 }, | ||
{ rating: 4 }, | ||
{ rating: 3 }, | ||
{ rating: 2 }, | ||
{ rating: 1 }, | ||
]; | ||
expect(GetAvgRating(ratings)).toBe(3); | ||
}); | ||
|
||
it("should correctly round the average rating to one decimal place", () => { | ||
const ratings = [{ rating: 5 }, { rating: 4 }, { rating: 4 }]; | ||
expect(GetAvgRating(ratings)).toBe(4.3); | ||
}); | ||
}); |