From 77c51f68572e13001dd42743d6a9cee53915e20c Mon Sep 17 00:00:00 2001 From: NewBieCoderXD Date: Thu, 26 Sep 2024 14:26:30 +0700 Subject: [PATCH] lint and format --- src/scraper/updateAssignmentsOfCourse.ts | 2 +- tests/unit/updateAssignmentsOfCourse.test.ts | 35 -------------------- 2 files changed, 1 insertion(+), 36 deletions(-) diff --git a/src/scraper/updateAssignmentsOfCourse.ts b/src/scraper/updateAssignmentsOfCourse.ts index f142fc7..8583489 100644 --- a/src/scraper/updateAssignmentsOfCourse.ts +++ b/src/scraper/updateAssignmentsOfCourse.ts @@ -34,7 +34,7 @@ export default async function updateAssignmentsOfCourse( let hasNext = true for (let currentAssignmentItems = 5; hasNext; currentAssignmentItems += 5) { const scrapeResult = await scrapeAssignmentsOfPage(currentAssignmentItems) - + if (scrapeResult == undefined) { break } diff --git a/tests/unit/updateAssignmentsOfCourse.test.ts b/tests/unit/updateAssignmentsOfCourse.test.ts index 7db41ae..d0da217 100644 --- a/tests/unit/updateAssignmentsOfCourse.test.ts +++ b/tests/unit/updateAssignmentsOfCourse.test.ts @@ -1,4 +1,3 @@ -// jest.mock("@/scraper/updateAll") const mockScrapeAssignmentsOfPage = jest.fn() const mockExtractAssignmentsFromCheerio = jest.fn() const mockFetchAndCatch = jest.fn() @@ -37,34 +36,12 @@ jest.mock('@/scraper/extractAssignmentsFromCheerio', () => { }) import { Assignment } from '@/database/database' -import { updateAll } from '@/scraper/updateAll' import updateAssignmentsOfCourse from '@/scraper/updateAssignmentsOfCourse' -import { Course } from '@prisma/client' describe('updateAll', () => { - let fetchAndCatchResponse: string - let coursesFromUpdate: Course[] = [] - let assignmentsOfCourseFromUpdate: Record = {} - let hasNext: boolean = false let scrapedAssignmentCourseId: number = 0 let scrapedAssignments: Assignment[] = [] - const updateAllSpy = jest.fn(updateAll) - const course123 = { - mcvID: 123, - courseID: '2111031', - title: 'How to Rickroll 101', - year: 2023, - semester: 2, - } - const course540 = { - mcvID: 540, - courseID: '2111032', - title: 'How to Make Mcv bot 101', - year: 2023, - semester: 2, - } - const assignment456 = { mcvCourseID: 123, assignmentID: 456, @@ -104,15 +81,3 @@ describe('updateAll', () => { expect(result).toEqual(expected) }) }) - -function assertAndExpect( - result: unknown, - expected: string[], - updateAllSpy: jest.Mock -) { - for (const expectedStr of expected) { - expect([...expectedStr].length).toBeLessThanOrEqual(2000) - } - expect(result).toEqual(expected) - expect(updateAllSpy).toHaveBeenCalledTimes(1) -}