与Mocha Chai进行单元测试?

时间:2019-07-15 08:17:02

标签: mocha sinon chai sinon-chai

我有一个正在编写单元测试的打字稿文件。如何编写用于静态方法配置的单元测试。我正在用摩卡柴

import * as log4js from "log4js";
import { Express, Request, Response } from "express";

export class Test {
static configuration(app: Express) {
app.post('/config', function (req: Request, res: Response) {
    console.log('setting log with :', req.body);
    let categoryName: string = req.body.category;
    console.log('categoryName:', categoryName);
    let level: string = req.body.level;
    let logger: log4js.Logger = log4js.getLogger(categoryName);
    logger.level = level;
    res.send(categoryName);
 });

 app.get('/config/:categoryName', function (req: Request, res: Response) 
    {
    console.log('getting logger for :', req.params.categoryName);
    }

0 个答案:

没有答案