From af743a0571d55417599c8efa838a1d59593b3ada Mon Sep 17 00:00:00 2001 From: funkyLover Date: Mon, 28 Jun 2021 19:33:50 +0800 Subject: [PATCH] test: update unit test; --- lib/server/index.js | 3 ++- lib/server/mock.js | 5 ++++- package-lock.json | 2 +- test/test.local.ip.request.js | 2 +- test/test.proxy.js | 2 +- test/test.request.js | 2 +- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/server/index.js b/lib/server/index.js index 87810cd..c3171ba 100644 --- a/lib/server/index.js +++ b/lib/server/index.js @@ -6,8 +6,9 @@ const clearCache = require('../clearCache'); const { getStatus, setStatus, resetStaus } = require('./status'); const bodyParserMiddleware = require('koa-bodyparser'); const localMiddleware = require('./local'); -const mockMiddleware = require('./mock'); +const { mockMiddleware } = require('./mock'); const proxyMiddleware = require('./proxy'); + /** * 获取mock数据, 设置mock数据文件夹监听, 以及调用启动服务器方法启动服务器 * @param {String} mockPath - mock数据存放目录 diff --git a/lib/server/mock.js b/lib/server/mock.js index 2a329aa..3d2d389 100644 --- a/lib/server/mock.js +++ b/lib/server/mock.js @@ -165,4 +165,7 @@ async function getMockData(api, ctx) { }; } -module.exports = mockMiddleware; +module.exports = { + getMockConfig: getMockConfig, + mockMiddleware: mockMiddleware +}; diff --git a/package-lock.json b/package-lock.json index 648ae1d..18466a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "mock-server-local", - "version": "2.6.0", + "version": "2.6.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/test/test.local.ip.request.js b/test/test.local.ip.request.js index d159cd2..3301950 100644 --- a/test/test.local.ip.request.js +++ b/test/test.local.ip.request.js @@ -4,7 +4,7 @@ const Koa = require('koa'); const axios = require('axios'); const { getStatus, setStatus } = require('../lib/server/status'); const localMiddleware = require('../lib/server/local'); -const mockMiddleware = require('../lib/server/mock'); +const { mockMiddleware } = require('../lib/server/mock'); const send = require('koa-send'); jest.mock('../lib/server/status'); diff --git a/test/test.proxy.js b/test/test.proxy.js index d604f83..f51f417 100644 --- a/test/test.proxy.js +++ b/test/test.proxy.js @@ -1,6 +1,6 @@ const Koa = require('koa'); const axios = require('axios'); -const mockMiddleware = require('../lib/server/mock'); +const { mockMiddleware } = require('../lib/server/mock'); const proxyMiddleware = require('../lib/server/proxy'); const { getStatus } = require('../lib/server/status'); diff --git a/test/test.request.js b/test/test.request.js index a24ce17..b52fb61 100644 --- a/test/test.request.js +++ b/test/test.request.js @@ -1,6 +1,6 @@ const Koa = require('koa'); const axios = require('axios'); -const mockMiddleware = require('../lib/server/mock'); +const { mockMiddleware } = require('../lib/server/mock'); const { getStatus } = require('../lib/server/status'); jest.mock('../lib/server/index');