-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add return value to have better tests
- Loading branch information
Showing
1 changed file
with
6 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
class Order { | ||
export class Order { | ||
constructor() {} | ||
|
||
getOrderByUser(userId) { | ||
console.log('return order of user:', userId); | ||
return `return order of user:${userId}`; | ||
} | ||
} | ||
|
||
class User { | ||
export class User { | ||
private order: Order; | ||
constructor() { | ||
this.order = new Order(); | ||
} | ||
|
||
getUser(userId) { | ||
this.order.getOrderByUser(userId); | ||
const order = this.order.getOrderByUser(userId); | ||
console.log('return user and order of user with id:', userId); | ||
return order + ' for user' | ||
} | ||
} | ||
|
||
let user = new User(); | ||
let userId = 5; | ||
user.getUser(userId); | ||
user.getUser(userId); |