-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.js
99 lines (84 loc) · 2.48 KB
/
tests.js
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
var mocha = require('mocha')
var calculateScore = require('./scoring').calculateScore
var expect = require('chai').expect
var { describe, it } = mocha
describe('Scoring', function () {
it('returns the score for a quarterback', function () {
var player = {
name: 'Patrick Mahomes',
position: 'QB',
team: 'Kansas City',
stats: {
passing: {
attempts: 25,
completions: 18,
yards: 363,
touchdowns: 3,
interceptions: 0
},
rushing: { attempts: 3, yards: 22, touchdowns: 1, fumbles: 0 }
}
}
var score = calculateScore(player)
expect(score).to.equal(40.72)
})
it('returns the score for a running back', function () {
var player = {
name: 'LeSean McCoy',
position: 'RB',
team: 'Buffalo',
stats: {
rushing: { attempts: 18, yards: 103, touchdowns: 2, fumbles: 0 },
receiving: { receptions: 6, yards: 37, touchdowns: 0, fumbles: 0 },
return: {
kickreturn: { returns: 0, yards: 0, touchdowns: 0, fumbles: 0 },
puntreturn: { returns: 0, yards: 0, touchdowns: 0, fumbles: 0 },
},
}
}
var score = calculateScore(player)
expect(score).to.equal(32)
})
it('returns the score for a receiver', function () {
var player = {
name: 'Tyler Lockett',
position: 'WR',
team: 'Seattle',
stats: {
rushing: { attempts: 0, yards: 0, touchdowns: 0, fumbles: 0 },
receiving: { receptions: 6, yards: 91, touchdowns: 1, fumbles: 0 },
return: {
kickreturn: { returns: 2, yards: 16, touchdowns: 0, fumbles: 1 },
puntreturn: { returns: 3, yards: 107, touchdowns: 1, fumbles: 0 },
},
}
}
var score = calculateScore(player)
expect(score).to.equal(32.3)
})
it('returns the score for a tightend', function () {
var player = {
name: 'Rob Gronkowski',
position: 'TE',
team: 'New England',
stats: {
receiving: { receptions: 8, yards: 137, touchdowns: 2, fumbles: 0 },
}
}
var score = calculateScore(player)
expect(score).to.equal(33.7)
})
it('returns 0 when position is unknown', function () {
var player = {
name: 'Robbie Gould',
position: 'K',
team: 'San Francisco',
stats: {
fieldgoals: { attempts: 3, made: 2 },
xp: { attempts: 2, made: 2 }
}
}
var score = calculateScore(player)
expect(score).to.equal(0)
})
})