feat: Best Practices (#102)

* feat: best practices

* feat: add tests workflow

* feat: add best-practices workflow

* fix: wrong indentation in workflow
This commit is contained in:
doprz
2024-02-21 15:54:21 -06:00
parent fe599dfe75
commit 5eb7be246c
13 changed files with 1739 additions and 1756 deletions

View File

@@ -0,0 +1,12 @@
import { describe, expect, it } from 'vitest';
import { convertMinutesToIndex } from '../useFlattenedCourseSchedule';
describe('useFlattenedCourseSchedule', () => {
it('should convert minutes to index correctly', () => {
const minutes = 480; // 8:00 AM
const expectedIndex = 2; // (480 - 420) / 30 = 2
const result = convertMinutesToIndex(minutes);
expect(result).toBe(expectedIndex);
});
});

View File

@@ -1,4 +1,5 @@
import { CalendarCourseCellProps } from 'src/views/components/calendar/CalendarCourseCell/CalendarCourseCell';
import type { CalendarCourseCellProps } from 'src/views/components/calendar/CalendarCourseCell/CalendarCourseCell';
import useSchedules from './useSchedules';
const dayToNumber: { [day: string]: number } = {
@@ -26,7 +27,7 @@ export interface CalendarGridCourse {
totalColumns?: number;
}
const convertMinutesToIndex = (minutes: number): number => Math.floor(minutes - 420 / 30);
export const convertMinutesToIndex = (minutes: number): number => Math.floor(minutes - 420 / 30);
/**
* Get the active schedule, and convert it to be render-able into a calendar.