This repository was archived by the owner on Jan 14, 2024. It is now read-only.
generated from CodeYourFuture/CYF-Coursework-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 267
Expand file tree
/
Copy path5-writing-tests.js
More file actions
75 lines (61 loc) · 1.61 KB
/
5-writing-tests.js
File metadata and controls
75 lines (61 loc) · 1.61 KB
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
/*
For this exercise, the function has been written for you and you need to write
the tests.
This function takes a marking coursework score and converts it into a string
representing a grade (from A to E). It then returns the grade.
*/
function convertScoreToGrade(score) {
let grade = null;
if (score >= 80) {
grade = "A";
} else if (score >= 70) {
grade = "B";
} else if (score >= 60) {
grade = "C";
} else if (score >= 50) {
grade = "D";
} else {
grade = "E";
}
return grade;
}
/* ======= TESTS - FOR THIS EXERCISE YOU SHOULD MODIFY THEM! =====
- To run the tests for this exercise, run `npm test -- --testPathPattern 5-writing-tests.js`
- To run all exercises/tests in the mandatory folder, run `npm test`
- (Reminder: You must have run `npm install` one time before this will work!)
*/
/*
The first test has been written for you. You need to fix the test so that it
passes.
*/
test("a score of 83 is grade A", () => {
expect(convertScoreToGrade(83), "Z");
});
/*
The rest of the tests have comments describing what to test and you need to
write a matching test
*/
test.skip("a score of 71 is grade B", () => {
/* Remove the .skip above, then write the test body. */
});
/*
Write a test that checks a score of 68 is grade C
*/
/*
Write a test that checks a score of 55 is grade D
*/
/*
Write a test that checks a score of 68 is grade C
*/
/*
Write a test that checks a score of 55 is grade D
*/
/*
Write a test that checks a score of 49 is grade E
*/
/*
Write a test that checks a score of 30 is grade E
*/
/*
Write a test that checks a score of 70 is grade B
*/