"use strict"; var testConfig = require('../config'); var APIv1 = require('../../../src/doctor/include/endpoints').APIv1; var should = require("should"); var restTemplate = require('supertest').agent(testConfig.host); var userId = '48832ecc339111e6badcfa163e789456'; describe('Chat api', function () { // 发送系统消息 describe('when send SYSTEM message correctly', function () { it('should return 200', function (done) { var path = APIv1.Chats.Base + APIv1.Chats.SM; restTemplate.post(path) .send({ to: "Rose", title: "System Message", summary: "You have new job", contentType: "1", content: "The patient has been followed in the scheduler, please make new follow plan as soon as possible." } ).end(function (err, response) { }); }); }); // 发送私信 describe('when send PRIVATE message correctly', function () { it('should return 200', function (done) { var path = APIv1.Chats.Base + APIv1.Chats.PM; restTemplate.post(path) .send({ to: "Rose", title: "System Message", summary: "You have new job", contentType: "1", content: "The patient has been followed in the scheduler, please make new follow plan as soon as possible." }) .end(function (err, response) { }); }); }); // 发送群消息 describe('when send PRIVATE message with bad message format', function () { it('should return 200', function (done) { var path = APIv1.Chats.Base + APIv1.Chats.PM; restTemplate.post(path) .send({ from: userId, at: "Rose", group: "DiscussionGroupId", groupType: 1, contentType: 1, content: "The patient mess me up" }) .end(function (err, response) { }); restTemplate.post(path) .send({ from: userId, at: "", group: "DiscussionGroupId", groupType: 1, contentType: 1, content: "The patient mess me up" }).end(function (err, response) { }); }); }); // 所有聊天列表 describe('when get ALL CHAT list', function () { it('should return 200 and all chat list', function (done) { var path = APIv1.Chats.Base + APIv1.Chats.List + "?user_id=" + userId; restTemplate.get(path) .end(function (err, response) { console.log("User " + userId + "'s all chat list: \n", response.body); response.status.should.equal(200); done(); }); }); }); // 未读组数量 describe('when get ALL GROUP unread chat count', function () { it('should return 200 and group chat count', function (done) { var path = APIv1.Chats.Base + APIv1.Chats.GMUnreadCount + "?user_id=" + userId; restTemplate.get(path) .end(function (err, response) { console.log("User " + userId + "'s group chat count: \n", response.body); response.status.should.equal(200); done(); }); }) }); // 未读私信数量 describe('when get ALL PRIVATE unread chat list', function () { it('should return 200 and private chat count', function (done) { var path = APIv1.Chats.Base + APIv1.Chats.PMUnreadCount + "?user_id=" + userId; restTemplate.get(path) .end(function (err, response) { console.log("User " + userId + "'s private chat count: \n", response.body); response.status.should.equal(200); done(); }); }) }); // 所有未读消息数量 describe('when get ALL unread message count', function () { it('should return 200 and all unread message count', function (done) { var path = APIv1.Chats.Base + APIv1.Chats.UnreadMsgCount + "?user_id=" + userId; restTemplate.get(path) .end(function (err, response) { console.log("User " + userId + "'s all unread message count: \n", response.body); response.status.should.equal(200); done(); }); }); }); // 获取角标数 describe('when get badge number', function () { it('shout return 200 and badge number', function (done) { var path = APIv1.Application.Base + APIv1.Application.BadgeNo + "?user_id=" + userId; restTemplate.get(path) .end(function (err, response) { console.log("User " + userId + "'s badge number: \n", response.body); response.status.should.equal(200); done(); }); }); }); });