|
1 | 1 | var expect = require('chai').expect; |
2 | 2 |
|
3 | | -describe('04 function capScores', function() { |
| 3 | +describe('04 function increaseScore', function() { |
4 | 4 |
|
5 | 5 | it('doesn\'t exist', function() { |
6 | | - expect(capScores).to.not.be.undefined; |
| 6 | + expect(increaseScore).to.not.be.undefined; |
7 | 7 | }); |
8 | 8 |
|
9 | 9 | it('should be a function', function() { |
10 | | - expect(capScores).to.be.a('function'); |
| 10 | + expect(increaseScore).to.be.a('function'); |
11 | 11 | }); |
12 | 12 |
|
13 | 13 | it('should take a parameter', function() { |
14 | | - expect(capScores).to.have.length(1); |
| 14 | + expect(increaseScore).to.have.length(1); |
15 | 15 | }); |
16 | 16 |
|
17 | | - it('shouldn\'t change scores under 100', function() { |
| 17 | + it('shouldn\'t change scores under 95', function() { |
18 | 18 | var test = { |
19 | | - score: 99 |
| 19 | + score: 82 |
20 | 20 | }; |
21 | | - expect(capScores(test)).to.deep.equal({ |
22 | | - score: 99 |
| 21 | + expect(increaseScore(test)).to.deep.equal({ |
| 22 | + score: 94 |
23 | 23 | }); |
24 | 24 | }); |
25 | 25 |
|
26 | | - it('should change scores over 100 to 95', function() { |
| 26 | + it('should change scores over 95 to 95', function() { |
27 | 27 | var test = { |
28 | | - score: 101 |
| 28 | + score: 84 |
29 | 29 | }; |
30 | | - expect(capScores(test)).to.deep.equal({ |
| 30 | + expect(increaseScore(test)).to.deep.equal({ |
31 | 31 | score: 95 |
32 | 32 | }); |
33 | 33 | }); |
34 | 34 |
|
35 | 35 | }); |
36 | 36 |
|
37 | | -describe('04 var mySlightlyFixed', function() { |
| 37 | +describe('04 var mySlightlyChanged', function() { |
38 | 38 |
|
39 | | - it('doesn\'t exist', function() { |
40 | | - expect(mySlightlyFixed).to.not.be.undefined; |
41 | | - }); |
42 | | - |
43 | | - it('isn\'t an array', function() { |
44 | | - expect(mySlightlyFixed).to.be.an('array'); |
45 | | - }); |
46 | | - |
47 | | - it('doesn\'t increment scores by 12', function() { |
48 | | - expect(mySlightlyFixed).to.deep.equal([{ |
49 | | - "title": "Relational Databases", |
50 | | - "instructor": "Sean Quentin Lewis", |
51 | | - "name": "Ada Lovelace", |
52 | | - "score": 95, |
53 | | - "grade": "A" |
54 | | - }, { |
55 | | - "title": "3D Computer Graphics", |
56 | | - "instructor": "G.L. Webb", |
57 | | - "name": "Ada Lovelace", |
58 | | - "score": 95, |
59 | | - "grade": "B" |
60 | | - }, { |
61 | | - "title": "Front End Web Development", |
62 | | - "instructor": "Moe Zaick", |
63 | | - "name": "Ada Lovelace", |
64 | | - "score": 73, |
65 | | - "grade": "D" |
66 | | - }, { |
67 | | - "title": "Web Security", |
68 | | - "instructor": "Sue Denim", |
69 | | - "name": "Ada Lovelace", |
70 | | - "score": 93, |
71 | | - "grade": "B" |
72 | | - }, { |
73 | | - "title": "Javascript Fundamentals", |
74 | | - "instructor": "Jay Kweerie", |
75 | | - "name": "Ada Lovelace", |
76 | | - "score": 85, |
77 | | - "grade": "C" |
78 | | - }, { |
79 | | - "title": "Data Science", |
80 | | - "instructor": "Ford Fulkerson", |
81 | | - "name": "Ada Lovelace", |
82 | | - "score": 70, |
83 | | - "grade": "F" |
84 | | - }, { |
85 | | - "title": "Algorithm Design", |
86 | | - "instructor": "Gale Shapely", |
87 | | - "name": "Ada Lovelace", |
88 | | - "score": 95, |
89 | | - "grade": "A" |
90 | | - }, { |
91 | | - "title": "Data Abstraction", |
92 | | - "instructor": "Aster Ricks", |
93 | | - "name": "Ada Lovelace", |
94 | | - "score": 94, |
95 | | - "grade": "B" |
96 | | - }, { |
97 | | - "title": "Data Structures", |
98 | | - "instructor": "Brodal Q.", |
99 | | - "name": "Ada Lovelace", |
100 | | - "score": 95, |
101 | | - "grade": "B" |
102 | | - }, { |
103 | | - "title": "Networks", |
104 | | - "instructor": "Van Emde Boas", |
105 | | - "name": "Ada Lovelace", |
106 | | - "score": 77, |
107 | | - "grade": "D" |
108 | | - }]); |
| 39 | + it('should cap scores at 95', function() { |
| 40 | + var scores = mySlightlyChanged.map(function(x) { |
| 41 | + return x.score; |
| 42 | + }); |
| 43 | + expect(Math.max.apply(Math, scores)).to.equal(95); |
109 | 44 | }); |
110 | 45 |
|
111 | 46 | }); |
0 commit comments