All files / test/interface-proxy base_test.js

100% Statements 14/14
100% Branches 0/0
100% Functions 4/4
100% Lines 14/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 281x 1x   1x   1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x                    
import InterfaceProxy from '../../packages/interface-proxy';
import iProxy from './iProxy';
 
describe("InterfaceProxy", () => {
 
    it("is defined", () => {
        expect(InterfaceProxy).toBeDefined();
    });
    // 基础配置信息 & 功能
    it("can generate request method with base config and call callback with args after request success", (done) => {
        iProxy.user().then((data, response) => {
            expect(response.success).toBeTruthy();
            expect(response.data).toEqual(data);
            expect(data.method).toBe('GET');
            expect(data.baseUrl).toBe('/api/json/user');
            expect(data.query.job).toBe('jobless');
            expect(data.query.race).toBe('human');
            done();
        });
    });
});
 
// TODO
// 一个BUG 在 single 的情况下,用同一个方法异步快速连续发送两次请求 会出现一次回调都没有的情况
// single: true,
 
// TODO
// 失败回调 如果返回true 则继续调用默认失败回调 测试