-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
87 lines (66 loc) · 2.59 KB
/
index.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const findAppointment = require('./index');
let schedules = [
[['09:00', '11:30'], ['13:30', '16:00'], ['16:00', '17:30'], ['17:45', '19:00']],
[['09:15', '12:00'], ['14:00', '16:30'], ['17:00', '17:30']],
[['11:30', '12:15'], ['15:00', '16:30'], ['17:45', '19:00']]
];
describe('Finding appointment for 60 minutes', () => {
const bestPossibleTime = findAppointment(schedules, 60);
it('should not be null', () => {
expect(bestPossibleTime).not.toBeNull();
});
it('should has startTime and endTime as property', () => {
expect(bestPossibleTime.hasOwnProperty('startTime')).toBeTruthy();
expect(bestPossibleTime.hasOwnProperty('endTime')).toBeTruthy();
});
it('should get 12:15 as startTime and 13:15 as endTime', () => {
expect(bestPossibleTime.startTime).toBe('12:15');
expect(bestPossibleTime.endTime).toBe('13:15');
});
});
describe('Finding appointment for 130 minutes', () => {
const bestPossibleTime = findAppointment(schedules, 130);
it('should be null', () => {
expect(bestPossibleTime).toBeNull();
});
});
describe('Finding appointment for 75 minutes', () => {
const bestPossibleTime = findAppointment(schedules, 75);
it('should not be null', () => {
expect(bestPossibleTime).not.toBeNull();
});
it('should has startTime and endTime as property', () => {
expect(bestPossibleTime.hasOwnProperty('startTime')).toBeTruthy();
expect(bestPossibleTime.hasOwnProperty('endTime')).toBeTruthy();
});
it('should get 12:15 as startTime and 13:30 as endTime', () => {
expect(bestPossibleTime.startTime).toBe('12:15');
expect(bestPossibleTime.endTime).toBe('13:30');
});
});
describe('Finding appointment for 72 minutes', () => {
const bestPossibleTime = findAppointment(schedules, 72);
it('should not be null', () => {
expect(bestPossibleTime).not.toBeNull();
});
it('should has startTime and endTime as property', () => {
expect(bestPossibleTime.hasOwnProperty('startTime')).toBeTruthy();
expect(bestPossibleTime.hasOwnProperty('endTime')).toBeTruthy();
});
it('should get 12:15 as startTime and 13:27 as endTime', () => {
expect(bestPossibleTime.startTime).toBe('12:15');
expect(bestPossibleTime.endTime).toBe('13:27');
});
});
describe('Finding appointment for 90 minutes', () => {
const bestPossibleTime = findAppointment(schedules, 90);
it('should be null', () => {
expect(bestPossibleTime).toBeNull();
});
});
describe('Finding appointment for 76 minutes', () => {
const bestPossibleTime = findAppointment(schedules, 76);
it('should be null', () => {
expect(bestPossibleTime).toBeNull();
});
});