Skip to content

Commit

Permalink
refactor: add return value to have better tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vahidvdn committed Jul 27, 2024
1 parent 1324b60 commit aa8f4f4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/dependency-injection/bad-practice.ts
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);

0 comments on commit aa8f4f4

Please sign in to comment.