如何测试x-editable datepicker的结束?

时间:2016-07-12 14:49:10

标签: javascript jquery datepicker x-editable

我有x-editable datepicker,我正在测试它:

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

如何测试关闭datepicker?我尝试在不同元素上调用click(),在输入时调用blur(),但类datepicker-open仍然存在。

1 个答案:

答案 0 :(得分:0)

通过阅读源代码找到,datepicker添加mousedown事件,这样就可以了:

$('body').mousedown()