Search code examples
javascriptjquerydatepickerx-editable

How to test closing of x-editable datepicker?


I have x-editable datepicker and I'm testing it like this:

it('should open edit in place on click', function() {
    var $editable = $date.find('.x-editable');
    $editable.click();
    var $input = $date.find('input');
    expect($editable.hasClass('editable-open')).toBeTruthy();
    expect($editable.hasClass('datepicker-open')).toBeFalsy();
    expect($('.datepicker').length).toEqual(0);
    $input.click();
    expect($editable.hasClass('datepicker-open')).toBeTruthy();
    expect($('.datepicker').length).toEqual(1);
});

how can I test closing of datepicker? I've try to call click() on different element and also blur() on input but the class datepicker-open is still present.


Solution

  • Found by reading the source code, datepicker add mousedown event so this work:

    $('body').mousedown()