当我没有限制/去除测试通过的功能时.
然而,当我辩论该事件以防止服务器泛滥时,测试不再通过.摩卡输出AssertionError: expected execute to have been called at least once, but it was never called
应该注意的是,去抖动的呼叫在实时代码中没有错误地工作.这就是为什么我彻底搞砸了测试失败的原因.
考试:
describe('When information is entered into the search fields', function () {
it('vents up the search:for:churches command', function () {
var executeStub = sinon.stub(App, 'execute');
view = new SearchForm()
view.render();
view.$el.find('input[name=church_name]').val('baptist')
view.$el.find('input[name=zip]').val('61615')
view.$el.find('input[name=zip]').trigger($.Event('keypress'))
expect(executeStub).to.have.been.called
view.close();
PEP.execute.restore()
});
});
Run Code Online (Sandbox Code Playgroud)
无节流:
var SearchForm = Backbone.Marionette.ItemView.extend({
template: 'search_form',
events: {
'keypress [data-search-field]' : 'searchForChurches'
},
searchForChurches: function() {
console.log('not debounced')
var searchData = Backbone.Syphon.serialize(this);
App.execute("search:for:churches", …Run Code Online (Sandbox Code Playgroud) 我来自php,我刚开始用红宝石和铁轨切割牙齿.
编写以下内容是否有更高效或更"红宝石"的方式?
<% if !@user.twitter_url.empty? %>
<a class="twitter" href="<%= @user.twitter_url %>">Twitter</a>
<% end %>
<% if !@user.facebook_url.empty? %>
<a class="facebook" href="<%= @user.facebook_url %>">Facebook</a>
<% end %>
<% if !@user.google_plus_url.empty? %>
<a class="googleplus" href="<%= @user.google_plus_url %>">Google Plus</a>
<% end %>
<% if !@user.linked_in_url.empty? %>
<a class="linkedin" href="<%= @user.google_plus_url %>">Linked In</a>
<% end %>
Run Code Online (Sandbox Code Playgroud)