<commit_before>var expect = require("expect.js");
var rewire = require("rewire");
var adapter = rewire("../../lib/mid/adapter");

describe('adapter', function() {
    it('读取适配器逻辑，装载成功', function() {
        var call = adapter(__dirname + '/../mock/adapter');
        var res = {
            proxyData: {}
        };
        var req = {
            method: 'get',
            route: {
                path: '/a'
            }
        }
        var next = function() {};
        call(req, res, next);
        expect(res.proxyData).to.be(1);
    });

    it('读取配置装载多级目录的路由，装载成功', function() {
        var call = adapter(__dirname + '/../mock/adapter');
        var res = {
            proxyData: {}
        };
        var req = {
            method: 'get',
            route: {
                path: '/a/b'
            }
        }
        var next = function() {};
        call(req, res, next);
        expect(res.proxyData).to.be(2);
    });
})<commit_msg>增加适配器中间件的单元测试<commit_after>var expect = require("expect.js");
var rewire = require("rewire");
var adapter = rewire("../../lib/mid/adapter");

describe('adapter', function() {
    it('读取适配器逻辑，装载成功', function() {
        var call = adapter(__dirname + '/../mock/adapter');
        var res = {
            proxyData: {}
        };
        var req = {
            method: 'get',
            route: {
                path: '/a'
            },
            input:{
                config:{

                }
            }
        }
        var next = function() {};
        call(req, res, next);
        expect(res.proxyData).to.be(1);
    });

    it('读取配置装载多级目录的路由，装载成功', function() {
        var call = adapter(__dirname + '/../mock/adapter');
        var res = {
            proxyData: {}
        };
        var req = {
            method: 'get',
            route: {
                path: '/a/b'
            },
            input:{
                config:{
                    
                }
            }
        }
        var next = function() {};
        call(req, res, next);
        expect(res.proxyData).to.be(2);
    });

    it('测试配置固定适配器',function(){
        var call = adapter(__dirname + '/../mock/adapter');
        var res = {
            proxyData: {}
        };
        var req = {
            method: 'get',
            route: {
                path: '/a/f'
            },
            input:{
                config:{
                    adapter:'a_b'
                }
            }
        }
        var next = function() {};
        call(req, res, next);
        expect(res.proxyData).to.be(2);
    });
})
{'fraction_non_alphanumeric': 0.1624031007751938, 'fraction_numerical': 0.001937984496124031, 'mean_word_length': 1.1634534786253143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6241123', 'n_tokens_mistral': 787, 'n_tokens_neox': 805, 'n_words': 143}