Skip to content

Commit

Permalink
fix: Check that lunch has beginning and end, if there is lunch
Browse files Browse the repository at this point in the history
uncomment relevant tests

Issue TTLApp#214
  • Loading branch information
Anat Dagan committed Sep 30, 2020
1 parent 9221c1c commit 97e728f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions __tests__/__renderer__/classes/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ describe('Calendar class Tests', () => {
expect(calendar._hasInputError('', '', '23:00', '00:00')).toBeTruthy();
// TODO: Fix commented
// expect(calendar._hasInputError('not-valid-hour', '', '', 'not-valid-hour')).toBeTruthy();
//expect(calendar._hasInputError('00:00', '12:00', '', '20:00')).not.toBeTruthy();
//expect(calendar._hasInputError('00:00', '', '13:00', '20:00')).not.toBeTruthy();
expect(calendar._hasInputError('00:00', '12:00', '', '20:00')).toBeTruthy();
expect(calendar._hasInputError('00:00', '', '13:00', '20:00')).toBeTruthy();
});
});

Expand Down
7 changes: 6 additions & 1 deletion js/classes/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -853,16 +853,21 @@ class Calendar {
*/
_hasInputError(dayBegin, lunchBegin, lunchEnd, dayEnd) {
var dayValues = new Array();
if (validateTime(dayBegin)) {
var bDuringLunch = false;
if (validateTime(dayBegin)) {
dayValues.push(dayBegin);
}
if (validateTime(lunchBegin)) {
bDuringLunch = true;
dayValues.push(lunchBegin);
}
if (validateTime(lunchEnd)) {
if (!bDuringLunch) return true;
bDuringLunch = false;
dayValues.push(lunchEnd);
}
if (validateTime(dayEnd)) {
if (bDuringLunch) return true;
dayValues.push(dayEnd);
}
for (var index = 0; index < dayValues.length; index++) {
Expand Down

0 comments on commit 97e728f

Please sign in to comment.