Skip to content

Commit ebc978e

Browse files
committed
unittest
1 parent d21655c commit ebc978e

File tree

2 files changed

+86
-3
lines changed

2 files changed

+86
-3
lines changed

unit-testing/studio/index.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,34 @@
11

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

32+
633
module.exports = launchcode;
734

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,64 @@
11
// launchcode.test.js code:
22
const launchcode = require('../index.js');
3-
43
describe("Testing launchcode", function(){
54

65
// Write your unit tests here!
6+
test("checking organization",()=>{
7+
expect(launchcode.organization).toBe("nonprofit");
8+
})
79

8-
});
10+
test("checking executive director",()=>{
11+
expect(launchcode.executiveDirector).toBe("Jeff");
12+
})
13+
14+
test("checking the value of percentageCoolEmployees",()=>{
15+
expect(launchcode.percentageCoolEmployees).toBe(100);
16+
} )
17+
test("checking the program offered",()=>{
18+
expect(launchcode.programsOffered[0]).toBe("Web Development");
19+
}
20+
)
21+
test("checking the program offered",()=>{
22+
expect(launchcode.programsOffered[1]).toBe("Data Analysis");
23+
}
24+
)
25+
test("checking the program offered",()=>{
26+
expect(launchcode.programsOffered[2]).toBe("Liftoff");
27+
})
28+
test("checking the program offered size",()=>{
29+
expect(launchcode.programsOffered.length).toBe(3);
30+
})
31+
test("checking number divisible by 2",()=>{
32+
expect(launchcode.launchOutput(4)).toBe('Launch!');
33+
}
34+
)
35+
test("checking number divisible by 3",()=>{
36+
expect(launchcode.launchOutput(9)).toBe('Code!');
37+
}
38+
)
39+
test("checking number divisible by 5",()=>{
40+
expect(launchcode.launchOutput(25)).toBe('Rocks!');
41+
}
42+
)
43+
test("checking number divisible by 2&&3",()=>{
44+
expect(launchcode.launchOutput(6)).toBe('LaunchCode!');
45+
}
46+
)
47+
test("checking number divisible by 3&&5",()=>{
48+
expect(launchcode.launchOutput(15)).toBe('Code Rocks!');
49+
}
50+
)
51+
test("checking number divisible by 2&&5",()=>{
52+
expect(launchcode.launchOutput(10)).toBe('Launch Rocks! (CRASH!!!!)');
53+
}
54+
)
55+
test("checking number divisible by 2,3&&5",()=>{
56+
expect(launchcode.launchOutput(30)).toBe('LaunchCode Rocks!');
57+
}
58+
)
59+
test("checking number not divisible by 2,3&&5",()=>{
60+
expect(launchcode.launchOutput(17)).toBe("Rutabagas! That doesn't work.");
61+
}
62+
)
63+
}
64+
)

0 commit comments

Comments
 (0)