测试电子邮件是否以流星速度发送 [英] Test if email is send in Meteor Velocity
本文介绍了测试电子邮件是否以流星速度发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以确认在 Meteor Velocity 测试中正在发送电子邮件?
Is it possible to confirm emails are being sent in Meteor Velocity tests?
我以为我可以在 tests
中使用一个具有相同名称的方法来覆盖/复制该方法,但这不起作用.我试过这个:
I thought I could just have a method in tests
with the same name that override/duplicates the method, but that doesn't work. I tried this:
在我的常规代码中:
Meteor.methods(
email: (parameters) ->
sendAnEmail(parameters)
)
在测试
中:
Meteor.methods(
email: (parameters) ->
differentBehaviorForTesting(parameters)
# I could call some super() here if necessary
)
但这总是让我感到
Error: A method named 'email' is already defined
推荐答案
您还可以创建一个看起来像这样的电子邮件装置:
You can also create an email fixture that looks something like this:
var _fakeInboxCollection = new Package['mongo'].Mongo.Collection('Emails');
Meteor.startup(function () {
_clearState();
_initFakeInbox();
});
Meteor.methods({
'clearState': _clearState,
'getEmailsFromInboxStub': function () {
return _fakeInboxCollection.find().fetch()
}
});
function _initFakeInbox () {
_fakeInboxCollection.remove({});
Email.send = function (options) {
_fakeInboxCollection.insert(options);
};
}
function _clearState () {
_fakeInboxCollection.remove({});
}
这将允许您正常发送电子邮件并使用 DDP 清除/获取电子邮件.
This will allow you to send emails normally and also clear / fetch the emails using DDP.
这篇关于测试电子邮件是否以流星速度发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文