Skip to content

Commit d541695

Browse files
committed
inline setting method for id at Person's constructor
1 parent 2051a20 commit d541695

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/person/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export class Person {
22
constructor(id) {
3-
this.id = id;
3+
this._id = id;
44
}
55

66
get name() {

src/person/index.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ describe('Person', () => {
88
});
99

1010
it('should allow to configure an id', () => {
11-
const person = new Person();
12-
person.id = 123;
11+
const person = new Person(123);
1312
expect(person.id).toEqual(123);
1413
});
1514
});

0 commit comments

Comments
 (0)