im.client.patient.session.search.Test.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. "use strict";
  2. let assert = require('assert');
  3. let imClient = require('../../src/client/im.client');
  4. let userId = 'D2016008240003';
  5. describe('API: Patient Search', function () {
  6. // 搜索所有
  7. describe('search all object types', function () {
  8. it('return a message', function (done) {
  9. imClient.Sessions.Search.Patient.searchAll(userId, '哦', false,
  10. function (data) {
  11. assert(data.messages.length > 0, "Search must return at least one data");
  12. console.log(data);
  13. done();
  14. },
  15. function (xhr, status, error) {
  16. assert.ok(false, xhr.responseJSON.message);
  17. done();
  18. });
  19. });
  20. });
  21. // 搜索患者
  22. describe('search patients', function () {
  23. it('return a patient', function (done) {
  24. imClient.Sessions.Search.Patient.searchPatient(userId, '丽', 1, 10,
  25. function (data) {
  26. assert(data.users.length > 0, "Search must return at least one data");
  27. console.log(data);
  28. done();
  29. },
  30. function (xhr, status, error) {
  31. assert.ok(false, xhr.responseJSON.message);
  32. done();
  33. });
  34. });
  35. });
  36. // 搜索会话
  37. describe('search sessions', function () {
  38. it('return a session', function (done) {
  39. imClient.Sessions.Search.Patient.searchSessions(userId, '廖小', false, 1, 10,
  40. function (data) {
  41. assert(data.sessions.length > 0, "Search must return at least one data");
  42. console.log(data);
  43. done();
  44. },
  45. function (xhr, status, error) {
  46. assert.ok(false, xhr.responseJSON.message);
  47. done();
  48. });
  49. });
  50. });
  51. // 搜索会话消息
  52. describe('search messages', function () {
  53. it('return at least one message', function (done) {
  54. imClient.Sessions.Search.Patient.searchMessages(userId, '哦', 1, 10,
  55. function (data) {
  56. assert(data.messages.length > 0, "Search must return at least one data");
  57. console.log(data);
  58. done();
  59. },
  60. function (xhr, status, error) {
  61. assert.ok(false, xhr.responseJSON.message);
  62. done();
  63. });
  64. });
  65. });
  66. });