Skip to content

Commit 304ae43

Browse files
Quinton KornegayQuinton Kornegay
Quinton Kornegay
authored and
Quinton Kornegay
committed
Testing and Coding Unit Testing
1 parent ea61c9e commit 304ae43

File tree

2 files changed

+75
-2
lines changed

2 files changed

+75
-2
lines changed

unit-testing/studio/index.js

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,35 @@
11

22
let launchcode = {
3-
4-
}
3+
organization: "nonprofit",
4+
executiveDirector: "Jeff",
5+
percentageCoolEmployees: 100,
6+
programsOffered: ["Web Development", "Data Analysis", "Liftoff"],
7+
launchOutput: function (num) {
8+
let result = "";
9+
10+
if (num % 2 === 0) {
11+
result += "Launch";
12+
}
13+
if (num % 3 === 0) {
14+
result += "Code";
15+
}
16+
if (num % 5 === 0) {
17+
if (result.length > 0) {
18+
result += " ";
19+
}
20+
result += "Rocks";
21+
}
22+
if (result.length === 0) {
23+
result = "Rutabagas! That doesn't work.";
24+
} else {
25+
result += "!";
26+
}
27+
if (result === "Launch Rocks!") {
28+
result += " (CRASH!!!!)";
29+
}
30+
return result;
31+
}
32+
};
533

634
module.exports = launchcode;
735

unit-testing/studio/tests/launchcode.test.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,49 @@ describe("Testing launchcode", function(){
55

66
// Write your unit tests here!
77

8+
it ("should have a property called organization", function() {
9+
expect(launchcode.organization).toEqual("nonprofit");
10+
});
11+
it ("should have a propert called executiveDirector", function () {
12+
expect(launchcode.executiveDirector).toEqual("Jeff");
13+
});
14+
it ("should have aproperty called percentageCoolEmployees", function (){
15+
expect(launchcode.percentageCoolEmployees).toEqual(100)
16+
});
17+
it ("should have property called programsOffered", function (){
18+
expect(launchcode.programsOffered[0]).toEqual("Web Development");
19+
expect(launchcode.programsOffered[1]).toEqual("Data Analysis");
20+
expect(launchcode.programsOffered[2]).toEqual("Liftoff");
21+
expect(launchcode.programsOffered.length).toEqual(3);
22+
});
23+
24+
describe("should have a method, launchOutpu, which", function(){
25+
26+
it ("should return 'Launch!' for numbers evenly divisible by 2", function (){
27+
expect(launchcode.launchOutput(2)).toEqual("Launch!");
28+
});
29+
it ("should return 'Code!' for numbers evenly divisible by 3", function (){
30+
expect(launchcode.launchOutput(3)).toEqual("Code!");
31+
});
32+
it ("should return 'Rocks!' for numbers evenly divisible by 5", function (){
33+
expect(launchcode.launchOutput(5)).toEqual("Rocks!");
34+
});
35+
it ("should return 'LaunchCode!' for numbers evenly divisible by 2 and 3", function (){
36+
expect(launchcode.launchOutput(6)).toEqual("LaunchCode!");
37+
});
38+
it ("should return 'Code Rocks!' for numbers evenly divisible by 3 and 5", function (){
39+
expect(launchcode.launchOutput(15)).toEqual("Code Rocks!");
40+
});
41+
// change for new condition
42+
it ("should return 'Launch Rocks! (CRASH!!!!)' for numbers evenly divisable by 2 and 5", function (){
43+
expect(launchcode.launchOutput(10)).toEqual("Launch Rocks! (CRASH!!!!)");
44+
});
45+
it ("should return 'LaunchCode Rocks! for numbers evenly divisible by 2, 3, and 5", function (){
46+
expect(launchcode.launchOutput(30)).toEqual("LaunchCode Rocks!");
47+
});
48+
it ("numbers not evenly divisible by 2, 3, or 5", function (){
49+
expect(launchcode.launchOutput(7)).toEqual("Rutabagas! That doesn't work.");
50+
});
51+
});
52+
853
});

0 commit comments

Comments
 (0)