-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-game-scores.test.ts
47 lines (39 loc) · 1.33 KB
/
update-game-scores.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { describe, expect, it, beforeEach } from 'vitest'
import { updateGameScores } from '@/server/functions/update-game-scores'
import { updateTeams } from '@/server/functions/update-teams'
import { updateSchedule } from '@/server/functions/update-schedule'
import prisma from '../helpers/prisma'
describe('updateGameScores', () => {
beforeEach(async () => {
await updateTeams()
await updateSchedule()
})
it('should update game scores', async () => {
const game = await prisma.game.findFirst()
expect(game).not.toBeNull()
if (!game) return
await prisma.game.update({
where: {
// error handled in expect
id: game.id,
},
data: {
home_score: -1,
opponent_score: -1,
},
})
const game2 = await prisma.game.findUnique({
where: { id: game.id },
})
if (!game2) return
expect(game2.home_score).toBe(-1)
expect(game2.opponent_score).toBe(-1)
await updateGameScores()
const game3 = await prisma.game.findUnique({
where: { id: game.id },
})
if (!game3) return
expect(game3.home_score).toBe(game.home_score)
expect(game3.opponent_score).toBe(game.opponent_score)
})
})