Skip to content

Commit e8ee295

Browse files
committed
Exercises: Unit Testing
1 parent a8a1733 commit e8ee295

File tree

2 files changed

+60
-2
lines changed

2 files changed

+60
-2
lines changed

unit-testing/exercises/RPS.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,19 @@ function whoWon(player1,player2){
1717
}
1818

1919
return 'Player 1 wins!';
20-
}
20+
}
21+
module.exports = {
22+
whoWon: whoWon
23+
};
24+
25+
const test = require('../RPS.js');
26+
27+
test("returns 'Player 2 wins!' if P1 = rock & P2 = paper", function(){
28+
let output = test.whoWon('rock','paper');
29+
expect(output).toBe("Player 2 wins!");
30+
});
31+
32+
test("returns 'Player 2 wins!' if P1 = paper & P2 = scissors", function(){
33+
let output = test.whoWon('paper','scissors');
34+
expect(output).toBe("Player 2 wins!");
35+
});

unit-testing/exercises/checkFive.js

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,47 @@ function checkFive(num){
88
result = num + " is greater than 5.";
99
}
1010
return result;
11-
}
11+
}
12+
13+
const test = require('../checkFive.js');
14+
15+
const checkFive = require('../checkFive.js');
16+
17+
describe("checkFive", function(){
18+
19+
test("Descriptive feedback...", function() {
20+
//code here...
21+
});
22+
23+
});
24+
25+
const checkFive = require('../checkFive.js');
26+
27+
describe("checkFive", function(){
28+
29+
test("Descriptive feedback...", function(){
30+
let output = checkFive(2);
31+
});
32+
33+
});
34+
35+
const checkFive = require('../checkFive.js');
36+
37+
describe("checkFive", function(){
38+
39+
test("Descriptive feedback...", function(){
40+
let output = checkFive(2);
41+
expect(output).toEqual("2 is less than 5.");
42+
});
43+
44+
});
45+
46+
test("returns 'num is less than 5' when num < 5.", function() {
47+
// test code //
48+
});
49+
50+
expect(output).toBe("2 is less than 5.");
51+
52+
if (num > 5) {
53+
// sourcecode //
54+
}

0 commit comments

Comments
 (0)