We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
type
Employee
1 parent 06815da commit 2dd4c4eCopy full SHA for 2dd4c4e
src/example-01/emplyees/index.js
@@ -5,6 +5,10 @@ export class Employee {
5
this._type = type;
6
}
7
8
+ get type() {
9
+ return this._type;
10
+ }
11
+
12
validateType(arg) {
13
if (![`engineer`, `manager`, `salesman`].includes(arg))
14
throw new Error(`Employee cannot be of type ${arg}`);
src/example-01/emplyees/index.test.js
@@ -1,6 +1,11 @@
1
import { Employee } from '.';
2
3
describe('Employee', () => {
4
+ it('should have a type', () => {
+ const employee = new Employee('Kaio', 'engineer');
+ expect(employee.type).toBe('engineer');
+ });
it('should throw an error if type is not valid', () => {
expect(() => new Employee('Kaio', 'invalid')).toThrow('Employee cannot be of type invalid');
});
0 commit comments