Skip to content

Commit e0081ff

Browse files
committed
Add tests and function to getTimeOfDay()
1 parent 9185112 commit e0081ff

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<section class="intro">
2020
<h1 class="intro-title">Good ${morning}!</h1>
2121
<div class="intro-time">time</div>
22-
<div class="intro-dated">date</div>
22+
<div class="intro-date">date</div>
2323
<p class="intro-text"></p>
2424

2525
</section>
@@ -34,6 +34,7 @@ <h1 class="intro-title">Good ${morning}!</h1>
3434

3535
</footer>
3636
<script src="logic.js"></script>
37+
<script src="feature-intro.js"></script>
3738
<script src="feature-tube.js"></script>
3839
<script src="feature-meme.js"></script>
3940

logic.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,21 @@ const shadowedNames = [
3333
function requiresShadow(lineID){
3434
return shadowedNames.includes(lineID);
3535
}
36+
37+
38+
function getTimeOfDay(hour){
39+
if (hour > 5 && hour < 12) return "Morning";
40+
if (hour > 11 && hour < 18) return "Afternoon";
41+
if (hour > 17 && hour < 22) return "Evening";
42+
return "Night"
43+
}
44+
45+
46+
47+
3648
// request("https://corporatebs-generator.sameerkumar.website/",function (response){
3749
// console.log(response);
3850
// });
3951
if (typeof module !== "undefined") {
40-
module.exports = { getStatusClass, requiresShadow };
52+
module.exports = { getStatusClass, requiresShadow, getTimeOfDay };
4153
}

test/intro-logic.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const tape = require("tape");
2+
const logic = require("../logic.js");
3+
4+
tape("Check if tape is working", t => {
5+
t.pass();
6+
t.end();
7+
});
8+
9+
tape("Check if getTimeOfDay returns Morning", t => {
10+
11+
t.equal(logic.getTimeOfDay(7),"Morning");
12+
t.equal(logic.getTimeOfDay(9),"Morning");
13+
t.equal(logic.getTimeOfDay(11),"Morning");
14+
t.end();
15+
});
16+
17+
tape("Check if getTimeOfDay returns Afternoon", t => {
18+
19+
t.equal(logic.getTimeOfDay(17),"Afternoon");
20+
t.equal(logic.getTimeOfDay(15),"Afternoon");
21+
t.equal(logic.getTimeOfDay(12),"Afternoon");
22+
t.end();
23+
});
24+

0 commit comments

Comments
 (0)