Skip to content

Commit f2f4940

Browse files
committed
lesson6
1 parent 12b607d commit f2f4940

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

lesson6.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Session class that leverages Date
2+
class Session {
3+
constructor() {
4+
this.lastUpdate = Date.now()
5+
}
6+
7+
touch() {
8+
this.lastUpdate = Date.now()
9+
}
10+
}
11+
12+
// A potential implementation to watch the Date Object
13+
function spyOn(Object, method) { /*... */ }
14+
15+
// A common way of using a spy
16+
const dateSpy = spyOn(Date, 'now')
17+
18+
Date.now()
19+
20+
// A commong way of checking the spy
21+
console.log(dateSpy.called.length > 0)

0 commit comments

Comments
 (0)