0

变量“被调用”是假的,什么时候应该设置为真..为什么会这样?当被插件调用时它被设置为 true,但在闭包之外它仍然是 false。有点莫名其妙。在此先感谢您的任何指点。

(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");
    });    
})();
4

1 回答 1

0

ok()在成功回调之前调用了qunit函数。异步问题。

于 2012-09-08T09:11:53.557 回答