当应该设置为true时,变量“called”为false ..为什么会这样? 当插件调用时它被设置为true但在闭包之外它仍然是假的。 它有点莫名其妙。提前感谢任何指示。
(function() {
module("when InitializedApplication() is called");
test("it should call the success function", function () {
// arrange
$("#qunit-fixture").append(
'<script id="events-catalog-view-template"' +
' type="text/html"'+
' src="_events-catalog.view.html">' +
'</script>' +
'<div id="events-catalog-view-container"' +
' data-bind="template: {' +
' name="events-catalog-view-template" ' +
' afterRender="tpw.mediator.eventscatalog.setupViewDataBinding" ' +
' }"' +
'</div>'
);
var called = false;
// act
var init = TPW.InitializeApplication();
init({
logLevel: "debug",
success: function (successfullResolution) {
called = true;
},
error: function (failedResolution) {
}
});
// assert
ok(called, "success function called");
});
})();
答案 0 :(得分:0)
在成功回调之前调用了qunit ok()
函数。异步问题。