本文整理汇总了TypeScript中simple-mock.mock函数的典型用法代码示例。如果您正苦于以下问题:TypeScript mock函数的具体用法?TypeScript mock怎么用?TypeScript mock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mock函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: it
it("will reject expired incoming messages", function (done) {
const confirmMethod = simple.mock(AMQPSubscriberAdapter.prototype,
"confirmProcessedMessage");
const rejectMethod = simple.mock(AMQPSubscriberAdapter.prototype,
"rejectMessage");
const onMessageMethod = simple.mock();
consumer.on("message", onMessageMethod);
const expiredMessage = merge({}, fixtures.consumer_basic, {
meta: {ttl: 10000},
});
publisher.publish([
fixtures.consumer_basic,
expiredMessage,
fixtures.consumer_basic,
], function (err) {
if (err) return done(err);
setTimeout(function () {
expect(onMessageMethod.callCount).equals(2);
expect(onMessageMethod.calls[0].arg).deep.equals(fixtures.consumer_basic);
expect(onMessageMethod.calls[1].arg).deep.equals(fixtures.consumer_basic);
expect(rejectMethod.callCount).equals(1);
expect(confirmMethod.callCount).equals(2);
expect(rejectMethod.lastCall.k).above(confirmMethod.calls[0].k);
expect(rejectMethod.lastCall.k).below(confirmMethod.calls[1].k);
done();
}, 100);
});
});
开发者ID:tcdl,项目名称:msb,代码行数:35,代码来源:amqp.ts
示例2: applyBuildMocks
function applyBuildMocks(buildQueue : Array<any>) {
builds_mock.queue = buildQueue;
simple.mock(builds, 'getNextQueued').callFn(builds_mock.getNextQueued);
simple.mock(builds, 'markAsStarted').callFn(builds_mock.markAsStarted);
simple.mock(builds, 'markAsSuccess').callFn(builds_mock.markAsSuccess);
simple.mock(builds, 'markAsFailed').callFn(builds_mock.markAsFailed);
}
开发者ID:mserranom,项目名称:lean-ci-agent,代码行数:7,代码来源:index_test.ts
示例3: it
it("can wait for acks without any determined number of responses", function(done) {
producer.publish.callbackWith();
const endHandler = simple.mock();
const obj = new Requester({
waitForResponses: 0,
waitForAcksMs: 800,
});
simple.mock(obj, "listenForResponses").returnWith();
simple.mock(obj, "isAwaitingAcks").returnWith(true);
simple.mock(messageFactory, "createRequestMessage").returnWith({
topics: {to: "my:topic", response: "my:topic:response"},
});
obj
.on("end", endHandler)
.publish({});
expect((obj.listenForResponses as any).called).to.equal(true);
expect((obj.listenForResponses as any).lastCall.args[0]).to.equal("my:topic:response");
expect(producer.publish.called).to.equal(true);
expect(endHandler.called).to.equal(false);
done();
});
开发者ID:tcdl,项目名称:msb,代码行数:27,代码来源:requester.ts
示例4: it
it("should set serviceDetails dynamically", function (done) {
const fakeInterfaces = {
en0: [{
address: "1.2.3.4",
netmask: "255.255.255.0",
family: "IPv4",
mac: "60:03:08:92:27:88",
internal: false,
}],
};
simple.mock(require("os"), "networkInterfaces").returnWith(fakeInterfaces);
simple.mock(require("os"), "hostname").returnWith("abchost");
serviceDetails = require(serviceDetailsModulePath);
expect(serviceDetails.hostname).equals("abchost");
expect(serviceDetails.ip).equals("1.2.3.4");
expect(serviceDetails.pid).equals(process.pid);
expect(serviceDetails.name).to.be.a("string");
expect(!!serviceDetails.version.match(/\d+\.\d+\.\d+/)).to.be.true;
expect(serviceDetails.instanceId).length(24);
done();
});
开发者ID:tcdl,项目名称:msb,代码行数:25,代码来源:serviceDetails.ts
示例5: beforeEach
beforeEach(function (done) {
simple.restore();
simple.mock(connection, "publish");
simple.mock(connection, "exchange");
simple.mock(exchange, "declare");
simple.mock(publisher, "publishMessageStr");
done();
});
开发者ID:tcdl,项目名称:msb,代码行数:8,代码来源:publisher.ts
注:本文中的simple-mock.mock函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论