im.client.search.Test.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. },
  13. function (xhr, status, error) {
  14. assert.ok(false, xhr.responseJSON.message);
  15. done();
  16. });
  17. });
  18. });
  19. // 搜索医生
  20. describe('search doctors', function () {
  21. it('should return 200', function (done) {
  22. imClient.Search.searchDoctors('张',
  23. function (data) {
  24. assert(data.length > 0, "Search must return at least one data");
  25. },
  26. function (xhr, status, error) {
  27. assert.ok(false, xhr.responseJSON.message);
  28. done();
  29. });
  30. });
  31. });
  32. // 搜索会话
  33. describe('search sessions', function () {
  34. it('should return 200', function (done) {
  35. imClient.Search.searchSessions(userId, '小',
  36. function (data) {
  37. assert(data.length > 0, "Search must return at least one data");
  38. },
  39. function (xhr, status, error) {
  40. assert.ok(false, xhr.responseJSON.message);
  41. done();
  42. });
  43. });
  44. });
  45. // 搜索会话消息
  46. describe('search sessions', function () {
  47. it('should return 200', function (done) {
  48. imClient.Search.searchMessages(userId, '哦',
  49. function (data) {
  50. assert(data.length > 0, "Search must return at least one data");
  51. },
  52. function (xhr, status, error) {
  53. assert.ok(false, xhr.responseJSON.message);
  54. done();
  55. });
  56. });
  57. });
  58. });