Skip to content

Commit

Permalink
added tests for weekly scrape
Browse files Browse the repository at this point in the history
  • Loading branch information
tobyrushton committed Feb 29, 2024
1 parent 53c8aed commit 700a1c7
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions __tests__/integration/api/weekly-db-scrape.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { describe, it, expect, beforeEach } from 'vitest'
import { GET } from '@/app/api/cron/weekly-db-scrape/route'
import { updateTeams } from '@/server/functions/update-teams'
import prisma from '../../helpers/prisma'

describe('GET /api/cron/weekly-db-scrape', () => {
beforeEach(async () => {
await updateTeams()
})

it('should return 200', async () => {
const res = await GET()
expect(res.status).toBe(200)
})

it('should take less than 10 seconds', async () => {
const start = Date.now()
await GET()
const end = Date.now()
expect(end - start).toBeLessThan(10000)

// validate function worked
const count = await prisma.team.count()
expect(count).toBe(30)
const count2 = await prisma.game.count()
expect(count2).toBeGreaterThan(80)
})
})

0 comments on commit 700a1c7

Please sign in to comment.