Browse Source

会话测试

Sand 8 năm trước cách đây
mục cha
commit
86328c531d

+ 6 - 4
src/server/endpoints/v2/search.endpoint.js

@ -39,14 +39,16 @@ router.get("/", function (req, res) {
    let searcher = new MySqlSearcher();
    let searcher = new MySqlSearcher();
    ControllerUtil.regModelEventHandler(searcher, res);
    ControllerUtil.regModelEventHandler(searcher, res);
    if(target == 'all'){
    if (target == 'all') {
        searcher.searchAll(userId, keyword);
        searcher.searchAll(userId, keyword);
    } else if(target == 'doctor'){
    } else if (target == 'doctor') {
        searcher.searchDoctors(keyword, page, size)
        searcher.searchDoctors(keyword, page, size)
    } else if(target == 'sessions'){
    } else if (target == 'session') {
        searcher.searchSessions(userId, keyword, page, size);
        searcher.searchSessions(userId, keyword, page, size);
    } else if(target == 'message'){
    } else if (target == 'message') {
        searcher.searchMessages(userId, keyword, page, size);
        searcher.searchMessages(userId, keyword, page, size);
    } else {
        throw {message: "Unknown target type: " + target};
    }
    }
});
});

+ 13 - 2
test/client/im.client.search.Test.js

@ -14,6 +14,7 @@ describe('API: Search', function () {
                assert(data.length > 0, "Search must return at least one data");
                assert(data.length > 0, "Search must return at least one data");
                console.log(data);
                console.log(data);
                done();
                done();
            },
            },
            function (xhr, status, error) {
            function (xhr, status, error) {
@ -30,6 +31,8 @@ describe('API: Search', function () {
                function (data) {
                function (data) {
                    assert(data.length > 0, "Search must return at least one data");
                    assert(data.length > 0, "Search must return at least one data");
                    console.log(data);
                    done();
                    done();
                },
                },
                function (xhr, status, error) {
                function (xhr, status, error) {
@ -42,9 +45,13 @@ describe('API: Search', function () {
    // 搜索会话
    // 搜索会话
    describe('search sessions', function () {
    describe('search sessions', function () {
        it('should return 200', function (done) {
        it('should return 200', function (done) {
            imClient.Search.searchSessions(userId, '小', 1, 10,
            imClient.Search.searchSessions('D2016008240003', '黄', 1, 10,
                function (data) {
                function (data) {
                    assert(data.length > 0, "Search must return at least one data");
                    assert(data.length > 0, "Search must return at least one data");
                    console.log(data);
                    done();
                },
                },
                function (xhr, status, error) {
                function (xhr, status, error) {
                    assert.ok(false, xhr.responseJSON.message);
                    assert.ok(false, xhr.responseJSON.message);
@ -54,11 +61,15 @@ describe('API: Search', function () {
    });
    });
    // 搜索会话消息
    // 搜索会话消息
    describe('search sessions', function () {
    describe('search messages', function () {
        it('should return 200', function (done) {
        it('should return 200', function (done) {
            imClient.Search.searchMessages(userId, '哦', 1, 10,
            imClient.Search.searchMessages(userId, '哦', 1, 10,
                function (data) {
                function (data) {
                    assert(data.length > 0, "Search must return at least one data");
                    assert(data.length > 0, "Search must return at least one data");
                    console.log(data);
                    done();
                },
                },
                function (xhr, status, error) {
                function (xhr, status, error) {
                    assert.ok(false, xhr.responseJSON.message);
                    assert.ok(false, xhr.responseJSON.message);