File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ // Permissions implementation does not matter
2+ import { Permissions } from '@/lib/permissions'
3+
4+ // Check what should be tested
5+ class User {
6+
7+ // NO
8+ constructor ( details , traits = { } ) {
9+ const { firstname, lastname } = details
10+ this . firstname = firstname
11+ this . lastname = lastname
12+ this . traits = traits
13+
14+ this . sessionStartedAt = Date . now ( )
15+ }
16+
17+ // YES
18+ get name ( ) {
19+ return `${ this . firstname } ${ this . lastname } `
20+ }
21+
22+ // YES
23+ get isAdmin ( ) {
24+ return Permissions . granted ( this , 'admin' )
25+ }
26+
27+ // YES in combination
28+ get currentSessionIsValid ( ) {
29+ const tenMinutesInMiliseconds = 600000
30+ return ( this . sessionStartedAt + tenMinutesInMiliseconds ) <= Date . now ( )
31+ }
32+
33+ extendSession ( ) {
34+ this . sessionStartedAt = Date . now ( )
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments