小编Apo*_*hah的帖子

使用确切参数调用的 Sinon js 检查存根

使用确切参数调用的 Sinon js 检查存根

要求:我想测试使用正确参数调用的 ejs.renderFile。

我的函数文件:html_to_pdf_converter.js

var ejsToPdfConvert = function (template, data, callback) {

    var row = data.voucher;
    html = ejs.renderFile(
        path.join(__dirname+'/../../views/', template),
        {
            data: data
        },
        function (error, success) {
            if (error) {
                callback(error, null);
            } else {

                var pdfPath = getPdfUploadPath(row);

                htmlToPdf.convertHTMLString(success, pdfPath, function (error, success) {
                    if (error) {
                        if (typeof callback === 'function') {
                            callback(error, null);
                        }

                    } else {
                        if (typeof callback === 'function') {
                            callback(null, success, pdfPath);
                        }
                    }
                });
            }
       });
 }; …
Run Code Online (Sandbox Code Playgroud)

javascript mocha.js node.js sinon chai

5
推荐指数
1
解决办法
7312
查看次数

标签 统计

chai ×1

javascript ×1

mocha.js ×1

node.js ×1

sinon ×1