-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmployee.test.js
54 lines (37 loc) · 1.58 KB
/
Employee.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
const Employee = require('../lib/employees/Employee');
const EnumEmployeeType = require('../lib/enum/EnumEmployeeType');
const testEmployeeName = 'Alice';
const testEmployeeId = 100;
const testEmployeeEmail = 'alice@gmail.com';
test('Can instantiate Employee instance', () => {
const employee = new Employee();
expect(typeof employee).toBe('object');
});
test('Can set name via constructor arguments', () => {
const employee = new Employee(testEmployeeName);
expect(employee.name).toBe(testEmployeeName);
});
test('Can set id via constructor argument', () => {
const employee = new Employee(testEmployeeName, testEmployeeId);
expect(employee.id).toBe(testEmployeeId);
});
test('Can set email via constructor argument', () => {
const employee = new Employee(testEmployeeName, testEmployeeId, testEmployeeEmail);
expect(employee.email).toBe(testEmployeeEmail);
});
test('Can get name via getName()', () => {
const employee = new Employee(testEmployeeName);
expect(employee.getName()).toBe(testEmployeeName);
});
test('Can get id via getId()', () => {
const employee = new Employee(testEmployeeName, testEmployeeId);
expect(employee.getId()).toBe(testEmployeeId);
});
test('Can get email via getEmail()', () => {
const employee = new Employee(testEmployeeName, testEmployeeId, testEmployeeEmail);
expect(employee.getEmail()).toBe(testEmployeeEmail);
});
test(`getRole() should return "${EnumEmployeeType.EMPLOYEE}"`, () => {
const employee = new Employee(testEmployeeName, testEmployeeId, testEmployeeEmail);
expect(employee.getRole()).toBe(EnumEmployeeType.EMPLOYEE);
});