Skip to content

Commit

Permalink
lint and format
Browse files Browse the repository at this point in the history
  • Loading branch information
NewBieCoderXD committed Sep 26, 2024
1 parent 08750db commit 77c51f6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 36 deletions.
2 changes: 1 addition & 1 deletion src/scraper/updateAssignmentsOfCourse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
35 changes: 0 additions & 35 deletions tests/unit/updateAssignmentsOfCourse.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// jest.mock("@/scraper/updateAll")
const mockScrapeAssignmentsOfPage = jest.fn()
const mockExtractAssignmentsFromCheerio = jest.fn()
const mockFetchAndCatch = jest.fn()
Expand Down Expand Up @@ -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<string, Assignment[]> = {}

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,
Expand Down Expand Up @@ -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)
}

0 comments on commit 77c51f6

Please sign in to comment.