1
私のバックボーンクラスで自分のメソッドをチェックしようとしています。コレクションにモデルを追加私の方法を確認するには、ビュー方式addNewFoodtypeBackboneJs Sinonのテスト
addNewFoodtype: function() {
var newFoodtype = $('#newFoodtype').val();
if (newFoodtype == "") {
console.log("Wpisz nazwę Typu jedzenia !!");
} else {
var newFoodtypeModel = new app.Foodtype({"name": _.escape(newFoodtype)});
this.collection.add(newFoodtypeModel);
// this.render();
}
},
1.Howで
describe("Foodtype View", function() {
before(function() {
this.$fixture = $("<div id='note-view-fixture'></div>");
});
beforeEach(function() {
// Empty out and rebind the fixture for each run.
this.$fixture.empty().appendTo($("#fixtures"));
this.spy = sinon.spy();
var a=[{"id":1,"name":"Pizza","lastModificationDate":"2017-02-03T09:01:58.754Z"}];
this.view = new app.FoodtypeView({
el: this.$fixture,
collection: new app.FoodtypeCollection(a)
});
});
after(function() {
// Remove all subfixtures after test suite finishes.
$("#fixtures").empty();
});
it("Adding models", function() {
this.view.addNewFoodtype(this.spy);
});
をこの方法では動作しますが、私はmochaJSでユニットテストを書くことに必要な、SinonJS
? 2.パラメータ "var newFoodtype = $( '#newFoodtype')。val();を渡す方法を教えてください。私の見解では