本文整理匯總了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);
});