diff --git a/src/batch/coursebook/sugangsnu/SugangSnuLectureService.ts b/src/batch/coursebook/sugangsnu/SugangSnuLectureService.ts index 7effb2ed..dbef2a38 100644 --- a/src/batch/coursebook/sugangsnu/SugangSnuLectureService.ts +++ b/src/batch/coursebook/sugangsnu/SugangSnuLectureService.ts @@ -49,7 +49,8 @@ function getRefLectureFromSugangSnuLecture(year: number, semester: number, lectu let quota = parseInt(sugangSnuLecture.quota.split(" ")[0]); let parsedClassTime = parseClassTime(sugangSnuLecture.class_time); - let timeJson = TimePlaceUtil.timeAndPlaceToJson(parsedClassTime, sugangSnuLecture.location); + const realClassTime = sugangSnuLecture.class_time + let timeJson = TimePlaceUtil.timeAndPlaceToJson(parsedClassTime, sugangSnuLecture.location, realClassTime); if (timeJson === null) { logger.warn("timeJson not found from (" + sugangSnuLecture.class_time + ", " + sugangSnuLecture.location + ")"); } diff --git a/src/core/timetable/model/TimePlace.ts b/src/core/timetable/model/TimePlace.ts index d4f1c577..b3170a90 100644 --- a/src/core/timetable/model/TimePlace.ts +++ b/src/core/timetable/model/TimePlace.ts @@ -2,5 +2,7 @@ export default interface TimePlace { day: number; start: number; len: number; + start_time: string; + end_time: string; place: string; }; diff --git a/src/core/timetable/util/TimePlaceUtil.ts b/src/core/timetable/util/TimePlaceUtil.ts index 7311a782..a35bfc67 100644 --- a/src/core/timetable/util/TimePlaceUtil.ts +++ b/src/core/timetable/util/TimePlaceUtil.ts @@ -6,7 +6,7 @@ import InvalidLectureTimeJsonError from '../../lecture/error/InvalidLectureTimeJ var logger = winston.loggers.get('default'); -export function timeAndPlaceToJson(timesString: string, locationsString: string): TimePlace[] { +export function timeAndPlaceToJson(timesString: string, locationsString: string, realTimesString: string): TimePlace[] { try { // 시간 정보가 없다면 빈 정보를 반환한다. if (timesString === '') { @@ -15,6 +15,7 @@ export function timeAndPlaceToJson(timesString: string, locationsString: string) let locations = locationsString.split('/'); let times = timesString.split('/'); + let realTimes = realTimesString.split('/') // 만약 강의실이 하나 뿐이거나 없다면, 시간에 맞춰서 강의 장소를 추가해준다. if (locations.length != times.length) { @@ -31,8 +32,11 @@ export function timeAndPlaceToJson(timesString: string, locationsString: string) } } - let classes = times.map((time, idx) => { + let classes = times.map((time, idx) => { let timeSplitted = time.split('-'); + const parsedRealTimes = realTimes[idx].match(/\d{2}:\d{2}/g) + const startTime = parsedRealTimes[0] + const endTime = parsedRealTimes[1] let day = ['월', '화', '수', '목', '금', '토', '일'].indexOf(timeSplitted[0].charAt(0)); let start = Number(timeSplitted[0].slice(2)); let len = Number(timeSplitted[1].slice(0, -1)); @@ -40,6 +44,8 @@ export function timeAndPlaceToJson(timesString: string, locationsString: string) return { day, start, + start_time: startTime, + end_time: endTime, len, place }; @@ -63,11 +69,13 @@ export function timeAndPlaceToJson(timesString: string, locationsString: string) // Merge same time with different location // Merge continuous time with same location + // TODO: 연속된 강의 머지기능 유지 논의 for (let i = 1; i < classes.length; i++) { let prev = classes[i-1]; let curr = classes[i]; if (prev.day == curr.day && prev.place == curr.place && curr.start == (prev.start + prev.len)) { prev.len += curr.len; + prev.end_time = curr.end_time classes.splice(i--, 1); } else if (prev.day == curr.day && prev.start == curr.start && prev.len == curr.len) { prev.place += '/' + curr.place; @@ -77,7 +85,7 @@ export function timeAndPlaceToJson(timesString: string, locationsString: string) return classes; } catch (err) { logger.error(err); - logger.error("Failed to parse timePlace (times: " + timesString + ", locations: " + locationsString + ")"); + logger.error("Failed to parse timePlace (times: " + timesString + ", locations: " + locationsString + ", realTime: " + realTimesString + ")"); return []; } } @@ -130,4 +138,4 @@ export function timeJsonToMask(timeJson:Array, duplicateCheck?:boolea timeMasks.push(mask); } return timeMasks; - } \ No newline at end of file + } diff --git a/test/batch/coursebook/sugangsnu/SugangSnuLectureServiceIntegrationTest.ts b/test/batch/coursebook/sugangsnu/SugangSnuLectureServiceIntegrationTest.ts index 3b7bb9b4..937cfffc 100644 --- a/test/batch/coursebook/sugangsnu/SugangSnuLectureServiceIntegrationTest.ts +++ b/test/batch/coursebook/sugangsnu/SugangSnuLectureServiceIntegrationTest.ts @@ -39,7 +39,7 @@ describe("SugangSnuLectureServiceIntegrationTest", function() { course_title: '그린리더십 인턴십', credit: 3, class_time: '금(6-3)', - class_time_json: [ { day: 4, start: 6, len: 3, place: '220-202' } ], + class_time_json: [ { day: 4, start: 6, len: 3, place: '220-202', start_time: '14:00', end_time: '16:50' } ], class_time_mask: [ 0, 0, 0, 0, 258048, 0, 0 ], instructor: '류재명', quota: 40, diff --git a/test/core/timetable/util/TimePlaceUtilUnitTest.ts b/test/core/timetable/util/TimePlaceUtilUnitTest.ts index 5be0585d..ac497b17 100644 --- a/test/core/timetable/util/TimePlaceUtilUnitTest.ts +++ b/test/core/timetable/util/TimePlaceUtilUnitTest.ts @@ -2,304 +2,360 @@ import assert = require('assert'); import TimePlaceUtil = require('@app/core/timetable/util/TimePlaceUtil'); import TimePlace from '@app/core/timetable/model/TimePlace'; -describe('TimePlaceUtilUnitTest', function() { - it("timeAndPlaceToJson__success__emptyTimeString", async function() { - assert.deepEqual([], TimePlaceUtil.timeAndPlaceToJson('','')); - }) +describe('TimePlaceUtilUnitTest', function () { + it("timeAndPlaceToJson__success__emptyTimeString", async function () { + assert.deepEqual([], TimePlaceUtil.timeAndPlaceToJson('', '', '')); + }) - it("timeAndPlaceToJson__success__coursesInDifferentDay", async function() { - assert.deepEqual([{day: 1, start:1, len:2, place: '220-317'}, - {day:3, start:1, len:2, place: '220-317'}], - TimePlaceUtil.timeAndPlaceToJson('화(1-2)/목(1-2)', '220-317/220-317')); - }) + it("timeAndPlaceToJson__success__coursesInDifferentDay", async function () { + assert.deepEqual([{day: 1, start: 1, len: 2, start_time: '09:00', end_time: '10:50', place: '220-317'}, + {day: 3, start: 1, len: 2, start_time: '09:00', end_time: '10:50', place: '220-317'}], + TimePlaceUtil.timeAndPlaceToJson('화(1-2)/목(1-2)', '220-317/220-317', '화(09:00~10:50)/목(09:00~10:50)')); + }) - it("timeAndPlaceToJson__success__onlyOneLocation", async function() { - assert.deepEqual([{day: 1, start:1, len:2, place: '220-317'}, - {day:3, start:1, len:2, place: '220-317'}], - TimePlaceUtil.timeAndPlaceToJson('화(1-2)/목(1-2)', '220-317')); - }) + it("timeAndPlaceToJson__success__onlyOneLocation", async function () { + assert.deepEqual([{day: 1, start: 1, len: 2, start_time: '09:00', end_time: '10:50', place: '220-317'}, + {day: 3, start: 1, len: 2, start_time: '09:00', end_time: '10:50', place: '220-317'}], + TimePlaceUtil.timeAndPlaceToJson('화(1-2)/목(1-2)', '220-317', '화(09:00~10:50)/목(09:00~10:50)')); + }) - it("timeAndPlaceToJson__success__emptyLocation", async function() { - assert.deepEqual([{day: 1, start:1, len:2, place: ''}, - {day:3, start:1, len:2, place: ''}], - TimePlaceUtil.timeAndPlaceToJson('화(1-2)/목(1-2)', '/')); - }) + it("timeAndPlaceToJson__success__emptyLocation", async function () { + assert.deepEqual([{day: 1, start: 1, len: 2, start_time: '09:00', end_time: '10:50', place: ''}, + {day: 3, start: 1, len: 2, start_time: '09:00', end_time: '10:50', place: ''}], + TimePlaceUtil.timeAndPlaceToJson('화(1-2)/목(1-2)', '/', '화(09:00~10:50)/목(09:00~10:50)')); + }) - it("timeAndPlaceToJson__success__noLocation", async function() { - assert.deepEqual([{day: 1, start:1, len:2, place: ''}, - {day:3, start:1, len:2, place: ''}], - TimePlaceUtil.timeAndPlaceToJson('화(1-2)/목(1-2)', '')); - }) + it("timeAndPlaceToJson__success__noLocation", async function () { + assert.deepEqual([{day: 1, start: 1, len: 2, start_time: '09:00', end_time: '10:50', place: ''}, + {day: 3, start: 1, len: 2, start_time: '09:00', end_time: '10:50', place: ''}], + TimePlaceUtil.timeAndPlaceToJson('화(1-2)/목(1-2)', '', '화(09:00~10:50)/목(09:00~10:50)')); + }) - it("timeAndPlaceToJson__success__floatingPointTime", async function() { - assert.deepEqual([{day: 1, start:1.5, len:2, place: '220-317'}, - {day:3, start:1.5, len:2, place: '220-317'}], - TimePlaceUtil.timeAndPlaceToJson('화(1.5-2)/목(1.5-2)', '220-317/220-317')); - }) + it("timeAndPlaceToJson__success__floatingPointTime", async function () { + assert.deepEqual([{day: 1, start: 1.5, len: 2, place: '220-317', start_time: '09:30', end_time: '11:20'}, + {day: 3, start: 1.5, len: 2, place: '220-317', start_time: '09:30', end_time: '11:20'}], + TimePlaceUtil.timeAndPlaceToJson('화(1.5-2)/목(1.5-2)', '220-317/220-317', '화(09:30~11:20)/목(09:30~11:20)')); + }) - it("timeAndPlaceToJson__success__coursesInSameDay", async function() { - assert.deepEqual([{day: 1, start:3, len:1, place: '302-208'}, - {day: 3, start:3, len:1, place: '302-208'}, - {day: 3, start:11, len:2, place: '302-310-2'}], - TimePlaceUtil.timeAndPlaceToJson('화(3-1)/목(3-1)/목(11-2)', '302-208/302-208/302-310-2')); - }) + it("timeAndPlaceToJson__success__coursesInSameDay", async function () { + assert.deepEqual([{day: 1, start: 3, len: 1, place: '302-208', start_time: '11:00', end_time: '11:50'}, + {day: 3, start: 3, len: 1, place: '302-208', start_time: '11:00', end_time: '11:50'}, + {day: 3, start: 11, len: 2, place: '302-310-2', start_time: '19:00', end_time: '20:50'}], + TimePlaceUtil.timeAndPlaceToJson('화(3-1)/목(3-1)/목(11-2)', '302-208/302-208/302-310-2', '화(11:00~11:50)/목(11:00~11:50)/목(19:00~20:50)')); + }) - it("timeAndPlaceToJson__success__mergeContinuousCourse", async function() { - assert.deepEqual([{day: 3, start: 9, len: 4, place: '220-317'}], - TimePlaceUtil.timeAndPlaceToJson('목(9-2)/목(11-2)', '220-317/220-317')); - }) + it("timeAndPlaceToJson__success__mergeContinuousCourse", async function () { + assert.deepEqual([{day: 3, start: 9, len: 4, place: '220-317', start_time: '17:00', end_time: '20:50'}], + TimePlaceUtil.timeAndPlaceToJson('목(9-2)/목(11-2)', '220-317/220-317', '목(17:00~18:50)/목(19:00~20:50)')); + }) - it("timeAndPlaceToJson__success__doNotMergeContinuousCourseButDiffLocation", async function() { - assert.deepEqual([ - {day: 3, start: 9, len: 2, place: '220-317'}, - {day: 3, start: 11, len: 2, place: '220-316'} - ], - TimePlaceUtil.timeAndPlaceToJson('목(9-2)/목(11-2)', '220-317/220-316')); - }) + it("timeAndPlaceToJson__success__doNotMergeContinuousCourseButDiffLocation", async function () { + assert.deepEqual([ + {day: 3, start: 9, len: 2, place: '220-317', start_time: '17:00', end_time: '18:50'}, + {day: 3, start: 11, len: 2, place: '220-316', start_time: '19:00', end_time: '20:50'} + ], + TimePlaceUtil.timeAndPlaceToJson('목(9-2)/목(11-2)', '220-317/220-316', '화(17:00~18:50)/목(19:00~20:50)')); + }) - it("timeAndPlaceToJson__success__mergeMultipleClassroom", async function() { - assert.deepEqual([ - {day: 0, start: 3, len: 1.5, place: '500-L302'}, - {day: 2, start: 3, len: 1.5, place: '500-L302'}, - {day: 4, start: 3, len: 2, place: '020-103/020-104'} - ], - TimePlaceUtil.timeAndPlaceToJson('월(3-1.5)/수(3-1.5)/금(3-2)/금(3-2)', '500-L302/500-L302/020-103/020-104')); - }) + it("timeAndPlaceToJson__success__mergeMultipleClassroom", async function () { + assert.deepEqual([ + {day: 0, start: 3, len: 1.5, place: '500-L302', start_time: '11:00', end_time: '12:15'}, + {day: 2, start: 3, len: 1.5, place: '500-L302', start_time: '11:00', end_time: '12:15'}, + {day: 4, start: 3, len: 2, place: '020-103/020-104', start_time: '11:00', end_time: '12:50'} + ], + TimePlaceUtil.timeAndPlaceToJson( + '월(3-1.5)/수(3-1.5)/금(3-2)/금(3-2)', + '500-L302/500-L302/020-103/020-104', + '월(11:00~12:15)/수(11:00~12:15)/금(11:00~12:50)/금(11:00~12:50)', + ) + ); + }) - it("timeAndPlaceToJson__success__mergeMultipleClassroom2", async function() { - assert.deepEqual([ - {day: 2, start: 7, len: 1, place: '014-B101'}, - {day: 2, start: 10, len: 1, place: '008-301/008-304/014-102/014-202/014-204/014-207'} - ], - TimePlaceUtil.timeAndPlaceToJson('수(10-1)/수(10-1)/수(7-1)/수(10-1)/수(10-1)/수(10-1)/수(10-1)', '008-301/008-304/014-B101/014-102/014-202/014-204/014-207')); - }) + it("timeAndPlaceToJson__success__mergeMultipleClassroom2", async function () { + assert.deepEqual([ + {day: 2, start: 7, len: 1, place: '014-B101', start_time: '15:00', end_time: '15:50'}, + {day: 2, start: 10, len: 1, place: '008-301/008-304/014-102/014-202/014-204/014-207', start_time: '18:00', end_time: '18:50'} + ], + TimePlaceUtil.timeAndPlaceToJson( + '수(10-1)/수(10-1)/수(7-1)/수(10-1)/수(10-1)/수(10-1)/수(10-1)', + '008-301/008-304/014-B101/014-102/014-202/014-204/014-207', + '수(18:00~18:50)/수(18:00~18:50)/수(15:00~15:50)/수(18:00~18:50)/수(18:00~18:50)/수(18:00~18:50)/수(18:00~18:50)', + ) + ); + }) - it("timeJsonToMask__success__emptyJson", async function() { - assert.deepEqual([0, 0, 0, 0, 0, 0, 0], TimePlaceUtil.timeJsonToMask([])); - }) + it("timeJsonToMask__success__emptyJson", async function () { + assert.deepEqual([0, 0, 0, 0, 0, 0, 0], TimePlaceUtil.timeJsonToMask([])); + }) - it("timeJsonToMask__success", async function() { - assert.deepEqual([0, parseInt("00011"+"11000"+"00000"+"00000"+"00000"+"00000", 2), 0, - parseInt("00011"+"11000"+"00000"+"00000"+"00000"+"00000", 2), 0, 0, 0], - TimePlaceUtil.timeJsonToMask([{day: 1, start:1.5, len:2, place: '220-317'}, - {day:3, start:1.5, len:2, place: '220-317'}])); - assert.deepEqual([0, parseInt("00011"+"11100"+"00000"+"00000"+"00000"+"00000", 2), 0, - parseInt("00011"+"11100"+"00000"+"00000"+"00000"+"00000", 2), 0, 0, 0], - TimePlaceUtil.timeJsonToMask([{day: 1, start:1.5, len:2.5, place: '220-317'}, - {day:3, start:1.5, len:2.5, place: '220-317'}])); - assert.deepEqual([0, parseInt("00001"+"11100"+"00000"+"00000"+"00000"+"00000", 2), 0, - parseInt("00001"+"11100"+"00000"+"00000"+"00000"+"00000", 2), 0, 0, 0], - TimePlaceUtil.timeJsonToMask([{day: 1, start:2, len:2, place: '220-317'}, - {day:3, start:2, len:2, place: '220-317'}])); - assert.deepEqual([0, parseInt("00000"+"00000"+"00000"+"00000"+"11111"+"11111", 2), 0, - parseInt("00000"+"00000"+"00000"+"00000"+"11111"+"11111", 2), 0, 0, 0], - TimePlaceUtil.timeJsonToMask([{day: 1, start:10, len:5, place: '220-317'}, - {day:3, start:10, len:5, place: '220-317'}])); - assert.deepEqual([0, parseInt("00000"+"00000"+"00000"+"00000"+"00000"+"01100", 2), 0, - parseInt("00000"+"00000"+"00000"+"00000"+"00000"+"01100", 2), 0, 0, 0], - TimePlaceUtil.timeJsonToMask([{day: 1, start: 13, len: 1, place: "302-308"}, - {day: 3, start: 13, len: 1, place: "302-308"}])); - assert.deepEqual([0, parseInt("00000"+"00000"+"00000"+"00000"+"00000"+"00000", 2), 0, - parseInt("00000"+"00000"+"00000"+"00000"+"00000"+"00000", 2), 0, 0, 0], - TimePlaceUtil.timeJsonToMask([{day: 1, start: -1, len: 1, place: "302-308"}, - {day: 3, start: 15, len: 1, place: "302-308"}])); - }); + it("timeJsonToMask__success", async function () { + assert.deepEqual([0, parseInt("00011" + "11000" + "00000" + "00000" + "00000" + "00000", 2), 0, + parseInt("00011" + "11000" + "00000" + "00000" + "00000" + "00000", 2), 0, 0, 0], + TimePlaceUtil.timeJsonToMask([{day: 1, start: 1.5, len: 2, place: '220-317', start_time: null, end_time: null}, + {day: 3, start: 1.5, len: 2, place: '220-317', start_time: null, end_time: null}])); + assert.deepEqual([0, parseInt("00011" + "11100" + "00000" + "00000" + "00000" + "00000", 2), 0, + parseInt("00011" + "11100" + "00000" + "00000" + "00000" + "00000", 2), 0, 0, 0], + TimePlaceUtil.timeJsonToMask([{day: 1, start: 1.5, len: 2.5, place: '220-317', start_time: null, end_time: null}, + {day: 3, start: 1.5, len: 2.5, place: '220-317', start_time: null, end_time: null}])); + assert.deepEqual([0, parseInt("00001" + "11100" + "00000" + "00000" + "00000" + "00000", 2), 0, + parseInt("00001" + "11100" + "00000" + "00000" + "00000" + "00000", 2), 0, 0, 0], + TimePlaceUtil.timeJsonToMask([{day: 1, start: 2, len: 2, place: '220-317', start_time: null, end_time: null}, + {day: 3, start: 2, len: 2, place: '220-317', start_time: null, end_time: null}])); + assert.deepEqual([0, parseInt("00000" + "00000" + "00000" + "00000" + "11111" + "11111", 2), 0, + parseInt("00000" + "00000" + "00000" + "00000" + "11111" + "11111", 2), 0, 0, 0], + TimePlaceUtil.timeJsonToMask([{day: 1, start: 10, len: 5, place: '220-317', start_time: null, end_time: null}, + {day: 3, start: 10, len: 5, place: '220-317', start_time: null, end_time: null}])); + assert.deepEqual([0, parseInt("00000" + "00000" + "00000" + "00000" + "00000" + "01100", 2), 0, + parseInt("00000" + "00000" + "00000" + "00000" + "00000" + "01100", 2), 0, 0, 0], + TimePlaceUtil.timeJsonToMask([{day: 1, start: 13, len: 1, place: "302-308", start_time: null, end_time: null}, + {day: 3, start: 13, len: 1, place: "302-308", start_time: null, end_time: null}])); + assert.deepEqual([0, parseInt("00000" + "00000" + "00000" + "00000" + "00000" + "00000", 2), 0, + parseInt("00000" + "00000" + "00000" + "00000" + "00000" + "00000", 2), 0, 0, 0], + TimePlaceUtil.timeJsonToMask([{day: 1, start: -1, len: 1, place: "302-308", start_time: null, end_time: null}, + {day: 3, start: 15, len: 1, place: "302-308", start_time: null, end_time: null}])); + }); - it("equalTimeJson__true", async function() { - let t1: Array = [ - { - day: 5, - start: 3, - len: 2, - place: "abcd" - }, - { - day: 3, - start: 3, - len: 2, - place: "abcg" - } - ]; + it("equalTimeJson__true", async function () { + let t1: Array = [ + { + day: 5, + start: 3, + len: 2, + place: "abcd", + start_time: null, + end_time: null + }, + { + day: 3, + start: 3, + len: 2, + place: "abcg", + start_time: null, + end_time: null + } + ]; - let t2: Array = [ - { - day: 5, - start: 3, - len: 2, - place: "abcd" - }, - { - day: 3, - start: 3, - len: 2, - place: "abcg" - } - ]; + let t2: Array = [ + { + day: 5, + start: 3, + len: 2, + place: "abcd", + start_time: null, + end_time: null + }, + { + day: 3, + start: 3, + len: 2, + place: "abcg", + start_time: null, + end_time: null + } + ]; - assert(TimePlaceUtil.equalTimeJson(t1, t2)); - }) + assert(TimePlaceUtil.equalTimeJson(t1, t2)); + }) - it("equalTimeJson__false__differLength", async function() { - let t1: Array = [ - { - day: 5, - start: 3, - len: 2, - place: "abcd" - } - ]; + it("equalTimeJson__false__differLength", async function () { + let t1: Array = [ + { + day: 5, + start: 3, + len: 2, + place: "abcd", + start_time: null, + end_time: null + } + ]; - let t2: Array = [ - { - day: 5, - start: 3, - len: 2, - place: "abcd" - }, - { - day: 3, - start: 3, - len: 2, - place: "abcd" - } - ]; + let t2: Array = [ + { + day: 5, + start: 3, + len: 2, + place: "abcd", + start_time: null, + end_time: null + }, + { + day: 3, + start: 3, + len: 2, + place: "abcd", + start_time: null, + end_time: null + } + ]; - assert(TimePlaceUtil.equalTimeJson(t1, t2) == false); - }) + assert(TimePlaceUtil.equalTimeJson(t1, t2) == false); + }) - it("equalTimeJson__false__differDay", async function() { - let t1: Array = [ - { - day: 5, - start: 3, - len: 2, - place: "abcd" - }, - { - day: 3, - start: 3, - len: 2, - place: "abcg" - } - ]; + it("equalTimeJson__false__differDay", async function () { + let t1: Array = [ + { + day: 5, + start: 3, + len: 2, + place: "abcd", + start_time: null, + end_time: null + }, + { + day: 3, + start: 3, + len: 2, + place: "abcg", + start_time: null, + end_time: null + } + ]; - let t2: Array = [ - { - day: 4, - start: 3, - len: 2, - place: "abcd" - }, - { - day: 3, - start: 3, - len: 2, - place: "abcg" - } - ]; + let t2: Array = [ + { + day: 4, + start: 3, + len: 2, + place: "abcd", + start_time: null, + end_time: null + }, + { + day: 3, + start: 3, + len: 2, + place: "abcg", + start_time: null, + end_time: null + } + ]; - assert(TimePlaceUtil.equalTimeJson(t1, t2) == false); - }) + assert(TimePlaceUtil.equalTimeJson(t1, t2) == false); + }) - it("equalTimeJson__false__differStart", async function() { - let t1: Array = [ - { - day: 5, - start: 3, - len: 2, - place: "abcd" - }, - { - day: 3, - start: 2, - len: 2, - place: "abcg" - } - ]; + it("equalTimeJson__false__differStart", async function () { + let t1: Array = [ + { + day: 5, + start: 3, + len: 2, + place: "abcd", + start_time: null, + end_time: null + }, + { + day: 3, + start: 2, + len: 2, + place: "abcg", + start_time: null, + end_time: null + } + ]; - let t2: Array = [ - { - day: 5, - start: 3, - len: 2, - place: "abcd" - }, - { - day: 3, - start: 3, - len: 2, - place: "abcg" - } - ]; + let t2: Array = [ + { + day: 5, + start: 3, + len: 2, + place: "abcd", + start_time: null, + end_time: null + }, + { + day: 3, + start: 3, + len: 2, + place: "abcg", + start_time: null, + end_time: null + } + ]; - assert(TimePlaceUtil.equalTimeJson(t1, t2) == false); - }) + assert(TimePlaceUtil.equalTimeJson(t1, t2) == false); + }) - it("equalTimeJson__false__differLen", async function() { - let t1: Array = [ - { - day: 5, - start: 3, - len: 1, - place: "abcd" - }, - { - day: 3, - start: 3, - len: 2, - place: "abcg" - } - ]; + it("equalTimeJson__false__differLen", async function () { + let t1: Array = [ + { + day: 5, + start: 3, + len: 1, + place: "abcd", + start_time: null, + end_time: null + }, + { + day: 3, + start: 3, + len: 2, + place: "abcg", + start_time: null, + end_time: null + } + ]; - let t2: Array = [ - { - day: 5, - start: 3, - len: 2, - place: "abcd" - }, - { - day: 3, - start: 3, - len: 2, - place: "abcg" - } - ]; + let t2: Array = [ + { + day: 5, + start: 3, + len: 2, + place: "abcd", + start_time: null, + end_time: null + }, + { + day: 3, + start: 3, + len: 2, + place: "abcg", + start_time: null, + end_time: null + } + ]; - assert(TimePlaceUtil.equalTimeJson(t1, t2) == false); - }) + assert(TimePlaceUtil.equalTimeJson(t1, t2) == false); + }) - it("equalTimeJson__false__differPlace", async function() { - let t1: Array = [ - { - day: 5, - start: 3, - len: 2, - place: "abcd" - }, - { - day: 3, - start: 3, - len: 2, - place: "abcgs" - } - ]; + it("equalTimeJson__false__differPlace", async function () { + let t1: Array = [ + { + day: 5, + start: 3, + len: 2, + place: "abcd", + start_time: null, + end_time: null + }, + { + day: 3, + start: 3, + len: 2, + place: "abcgs", + start_time: null, + end_time: null + } + ]; - let t2: Array = [ - { - day: 5, - start: 3, - len: 2, - place: "abcd" - }, - { - day: 3, - start: 3, - len: 2, - place: "abcg" - } - ]; + let t2: Array = [ + { + day: 5, + start: 3, + len: 2, + place: "abcd", + start_time: null, + end_time: null + }, + { + day: 3, + start: 3, + len: 2, + place: "abcg", + start_time: null, + end_time: null + } + ]; - assert(TimePlaceUtil.equalTimeJson(t1, t2) == false); - }) + assert(TimePlaceUtil.equalTimeJson(t1, t2) == false); + }) }); diff --git a/test/integration/index.ts b/test/integration/index.ts index 2e7702fc..c19a9424 100644 --- a/test/integration/index.ts +++ b/test/integration/index.ts @@ -89,6 +89,8 @@ describe('Integration Test', function() { "day": 1, "start": 13, "len": 1, + "start_time": "21:00", + "end_time": "22:00", "place": "302-308", "_id": "56fcd83c041742971bd20a88" }, @@ -96,6 +98,8 @@ describe('Integration Test', function() { "day": 3, "start": 13, "len": 1, + "start_time": "21:00", + "end_time": "22:00", "place": "302-308", "_id": "56fcd83c041742971bd20a87" }