Versuchen zu verstehen, Jasmine toHaveBeenCalled() matcher

Ich bin neu jasmine hier ist mein src - Datei, in die ich erstellen Auth Klasse

function Auth() {
}

Auth.prototype.isEmpty = function(str) {
    return (!str || 0 === str.length);
}

Auth.prototype.Login = function (username , password) {
    if (this.isEmpty(username) || this.isEmpty(password)) {
        return "Username or Password cann't be blank ";
    }
    else {
        return "Logged In !";
    }
}

nun will ich testen, jasmine toHaveBeenCalled() matcher . Hier ist, was ich Schreibe

it("should be able to Login", function () {
    spyOn(authobj);
    expect(authobj.Login('abc', 'abc')).toHaveBeenCalled();
});

aber Sie sagt, dass undefined() method does not exist

InformationsquelleAutor Ancient | 2013-05-28
Schreibe einen Kommentar