Skip to content

Commit d83fe11

Browse files
committed
ex-2: add capitalization logic to EmployeeType
1 parent 3fa0dfd commit d83fe11

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/example-02/emplyees/types/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ export class EmployeeType {
33
this.value = value;
44
}
55

6+
get capitalizedName() {
7+
return this.toString().charAt(0).toUpperCase() + this.toString().slice(1);
8+
}
9+
610
toString() {
711
return this.value;
812
}

src/example-02/emplyees/types/index.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,9 @@ describe('EmployeeType', () => {
55
const employeeType = new EmployeeType('engineer');
66
expect(employeeType.toString()).toBe('engineer');
77
});
8+
9+
it('should return the capitalized name', () => {
10+
const employeeType = new EmployeeType('manager');
11+
expect(employeeType.capitalizedName).toBe('Manager');
12+
});
813
});

0 commit comments

Comments
 (0)