From b8a8c44a678b55cc4bc3196e36c212d9a21e4bc4 Mon Sep 17 00:00:00 2001 From: livhong <13302010056@fudan.edu.cn> Date: Thu, 30 Jun 2016 19:30:37 +0800 Subject: [PATCH] fix some meetingtest bug --- api/service/dbService.js | 9 +++++++-- test/api/service/dbServiceMeetingTest.js | 9 ++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/api/service/dbService.js b/api/service/dbService.js index f6cce43..9af6936 100644 --- a/api/service/dbService.js +++ b/api/service/dbService.js @@ -145,11 +145,13 @@ var Meeting = { }, updateMeeting: function(meetings){ //mid, title, note, start_time, end_time, rid + //console.log("[updateMeeting] meetings: "+JSON.stringify(meetings)) return this.getMeetingByMid(meetings.mid).then(function(meeting){ if(!meeting){ return Promise.resolve(false); } var meetingFolder = AV.Object.createWithoutData('Meeting', meeting.get('objectId')); + //var meetingFolder = AV.Object.createWithoutData('Meeting', meeting.objectId); meetingFolder.set('title',meetings.title); meetingFolder.set('note',meetings.note); meetingFolder.set('start_time', meetings.start_time); @@ -157,14 +159,17 @@ var Meeting = { meetingFolder.set('rid', meetings.rid); return meetingFolder.save().then( ()=>Promise.resolve(true) - ,()=>Promise.resolve(false) + ,(error)=>{ + console.log("[updateMeeting ]error: "+JSON.stringify(error)); + return Promise.resolve(false) + } ); }); }, getMeetings: function(start, limit){ var query = new AV.Query('Meeting'); - query.skip(start); query.limit(limit); + query.skip(start); return query.find(); }, getMeetingsByTime: function(start_time, end_time){ diff --git a/test/api/service/dbServiceMeetingTest.js b/test/api/service/dbServiceMeetingTest.js index b6b1300..b9a32b2 100644 --- a/test/api/service/dbServiceMeetingTest.js +++ b/test/api/service/dbServiceMeetingTest.js @@ -35,7 +35,7 @@ describe('Meeting', function(){ i); } //console.log(JSON.stringify(meetings)) - + var uMeetings = []; describe('create', function(){ it('createMeeting', function(){ //var result = Promise.resolve(true); @@ -55,18 +55,21 @@ describe('Meeting', function(){ promiseList.push(Meeting.createMeeting(meeting.title, meeting.note, meeting.start_time, meeting.end_time, meeting.rid).then(function(res){ //console.log("[createMeeting] "+res.get('title')); + uMeetings.push(res); + //console.log("[createMeeting] "+JSON.stringify(res)); expect(res).to.be.ok; })); }); return Promise.all(promiseList); }) }) - var uMeetings; + describe('get', function(){ it('getMeetings', function(){ return Meeting.getMeetings(0, meetings.length).then(function(data){ - uMeetings = data; + //console.log("[getMeetings] data: "+JSON.stringify(data)) + //uMeetings = data; //data.forEach(function(meeting){ // meetings.forEach(function(item){ // if(item.rid==meeting.get('rid')){