/// <reference path="../../../Scripts/myObjectScript.js" />
module("My Test", {
setup: function () {
setUpDOM();
},
teardown: function () {
}
});
test("initialize. page load. setPrimaryWarning bound to change event of primary checkbox", function () {
myObject.Initialize();
var events = $("#Primary").data('events');
equal(1, events.length);
});
function setUpDOM() {
var $primaryCheckBox = "<input data-val='true' data-val-required='Need Primary' id='Primary' name='Primary' type='checkbox' value='false' data-blur-setup='true'>";
$("#qunit-fixture").append($primaryCheckBox);
}
失败,错误死于测试#1 undefined:无法获取属性'data'的值:object为null或undefined
如果我在chrome $(“#Primary”)中的开发工具中测试.data('events');将返回一个Object。任何想法我如何看待一个事件是否与qunit中的元素绑定或者我在上面测试的方式有什么问题?