I am new to JQuery and have to test this function with Jasmine:
showUserDeleted: function (event) {
$('#loginError').html((new ErrorView({code: "login"})).render().$el);
}
I devided this function into two:
showFailedLogin: function (event) {
var value = (new ErrorView({code: "login"})).render().$el;
showFailedLoginHelper(event, value);
},
showFailedLoginHelper: function (event, value){
$('#loginError').html(value);
},
Now I want to test the helper function.
//...
var view;
var $;
beforeAll(function(done){
require(['../../../public/js/app/views/LoginView', 'jquery'],
function(LoginView, Jquery) {
view = new LoginView();
$ = view.getJQuery();
done();
}
);
});
describe("showFailedLogin", function(){
it ("should add something to loginError", function(){
var input = "asdf";
view.showFailedLoginHelper(undefined, input);
expect( $('#loginError').html()).toBe(input);
});
});
//...
When I run this it says:
Expected undefined to be 'asdf'.
What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire