¿Por qué falla este cierre (javascript)?

The variable "called" is false when is should be set to true.. why is that? It is set to true when called by the plugin but outside the closure it remains false. Its a bit baffling. Thanks in advance for any pointers.

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

preguntado el 01 de septiembre de 12 a las 16:09

1 Respuestas

The qunit ok() function was being called before the success callback. Async problem.

Respondido el 08 de Septiembre de 12 a las 13:09

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.