本文整理汇总了TypeScript中Sinon.SinonSandbox.mock方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SinonSandbox.mock方法的具体用法?TypeScript SinonSandbox.mock怎么用?TypeScript SinonSandbox.mock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sinon.SinonSandbox
的用法示例。
在下文中一共展示了SinonSandbox.mock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("Errors on a low version", function(done) {
process.argv = command("node bst.js test");
setVersion("v3.0.0");
let errorCalls = 0;
const mockProcess = sandbox.mock(process);
mockProcess.expects("exit").once().withExactArgs(1);
mockery.registerMock("../lib/core/logging-helper", {
"LoggingHelper": {
prepareForFileLoggingAndDisableConsole: () => {},
info: function (level: any, message: string) {},
error: function (level: any, message: string) {
errorCalls++;
if (errorCalls === 1) {
assert.equal(message, "!!!!Node version must be >= 4!!!!");
}
if (errorCalls === 2) {
done();
}
}
}
});
NodeUtil.run("../../bin/bst.js");
});
示例2: it
it("Prints help with help parameter", function(done) {
process.argv = command("node bst-launch.js -h");
const mockProgram = sandbox.mock(require("commander"));
mockProgram.expects("outputHelp").once();
const mockProcess = sandbox.mock(process);
mockProcess.expects("exit").once().withExactArgs(0);
NodeUtil.load("../../bin/bst-launch.js");
setTimeout(function () {
try {
mockProgram.verify();
mockProcess.verify();
done();
} catch (assertionError) {
done(assertionError);
}
}, 100);
});