im.client.search.Test.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. "use strict";
  2. let assert = require('assert');
  3. let imClient = require('../../src/client/im.client');
  4. let userId = 'D2016008240002';
  5. describe('API: Search', function () {
  6. // 搜索所有
  7. describe('search all object types', function () {
  8. it('should return 200', function (done) {
  9. imClient.Search.searchAll(userId, '哦',
  10. function (data) {
  11. assert(data.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 doctors', function () {
  23. it('should return 200', function (done) {
  24. imClient.Search.searchDoctors(userId, '张', 1, 10,
  25. function (data) {
  26. assert(data.length > 0, "Search must return at least one data");
  27. done();
  28. },
  29. function (xhr, status, error) {
  30. assert.ok(false, xhr.responseJSON.message);
  31. done();
  32. });
  33. });
  34. });
  35. // 搜索会话
  36. describe('search sessions', function () {
  37. it('should return 200', function (done) {
  38. imClient.Search.searchSessions(userId, '小', 1, 10,
  39. function (data) {
  40. assert(data.length > 0, "Search must return at least one data");
  41. },
  42. function (xhr, status, error) {
  43. assert.ok(false, xhr.responseJSON.message);
  44. done();
  45. });
  46. });
  47. });
  48. // 搜索会话消息
  49. describe('search sessions', function () {
  50. it('should return 200', function (done) {
  51. imClient.Search.searchMessages(userId, '哦', 1, 10,
  52. function (data) {
  53. assert(data.length > 0, "Search must return at least one data");
  54. },
  55. function (xhr, status, error) {
  56. assert.ok(false, xhr.responseJSON.message);
  57. done();
  58. });
  59. });
  60. });
  61. });