1
我與sinon的fakeTimers有問題。這用於Marionette.js,下劃線和柴測試跑步者的環境中。如果我在chrome中設置了一個斷點並通過,我的計時器被觸發。但是,如果我沒有設置斷點,那麼它永遠不會被解僱。Sinon fakeTimers not firing
我正在使用_.debounce
這是導致計時器設置。
這裏是如何的定時器設置:
describe('Basket item view', function() {
beforeEach(function() {
this.clock = sinon.useFakeTimers();
this.app = new Backbone.Marionette.Application();
this.app.addInitializer(basketInit);
this.app.start(basketOptions);
this.basketListView = this.app.baskets.currentView;
this.basketViews = this.basketListView.children;
});
afterEach(function() {
this.app = this.basketListView = null;
this.clock.restore();
});
it('updates amount on quantity change', function() {
var basketLayoutView = this.basketViews.last();
var itemView = basketLayoutView.basket.currentView.children.first();
var items = basketLayoutView.collection;
var item = items.findWhere({id: 136});
var $quantity = itemView.$('input.quantity');
var updatedQuantity = 2;
var updatedPrice = '20.00';
$quantity.val(updatedQuantity);
$quantity.change();
this.clock.tick(500);
var newItemView = basketLayoutView.basket.currentView.children.first();
var $amount = newItemView.$('td.amount.total');
assert.equal(
item.get('quantity'), updatedQuantity,
'quantity change');
assert.equal(
$amount.text().trim(), updatedPrice,
'amount change');
});