All files / test/interface-proxy hook_test.js

100% Statements 13/13
100% Branches 0/0
100% Functions 7/7
100% Lines 13/13

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  1x       1x 1x 1x 1x       1x 1x 1x 1x       1x 1x 1x 1x      
// import {InterfaceProxy} from '../../src/index.js';
import iProxy from './iProxy';
 
describe("runtime hook", () => {
    // 配置项 hook paramsFilter
    it("should have config paramsFilter", (done) => {
        iProxy.superUser({job: 'police'}).then(data => {
            expect(data.query.job).toEqual('super-police');
            done();
        });
    });
    // 配置项 hook beforeSend
    it("should have beforeSend", (done) => {
        iProxy.userWithTokenHeader().then(data => {
            expect(data.headers['x-token']).toEqual('0001');
            done();
        });
    });
    // 配置项 hook successHandler
    it("should support hook successHandler to custom response state check", (done) => {
        iProxy.jsonFailAsSuccess().then(data => {
            expect(data).toEqual({success: false, msg: 'server error'});
            done();
        });
    });
});