JS-
JS-

Reputation: 957

Fake click event - jasmine

I have this function

daysClick: function(e) {

    var parent = $(e.currentTarget).closest('.days');

    if (!$(parent).hasClass('disabled') && !$(parent).hasClass('readonly')) {
        $(e.currentTarget).toggleClass('selected');
    }
}

How can I test this using jasmine?

I'm not sure how to fake click event basically.

Upvotes: 0

Views: 886

Answers (1)

Simon Adcock
Simon Adcock

Reputation: 3562

Have a look at uitest.js.

It allows you to incorporate event handling and other UI features into your automated Jasmine tests.

var uit = uitest.current;

describe('someSuite', function() {
    uit.url('someUrl');

    it('should do smth when clicked on the button', function() {
        uit.runs(function($) {
            $(".btn").click();
        });
    });
});

Upvotes: 1

Related Questions