Javascript .click()事件不会触发Jasmine测试中的函数

Javascript .click()事件不会触发Jasmine测试中的函数,javascript,jquery,jasmine,Javascript,Jquery,Jasmine,我试图测试jasmine 1.3和jQuery 1.7.2中的一个按钮,当我定义.click()函数时,它不会触发事件。 这是我的代码: describe("after collection loads files", function(){ beforeEach(function(){ this.filesColl._processFetchBatchResult( constructFetchBatchResult(this.filesAttrs, {IsTrunc

我试图测试jasmine 1.3和jQuery 1.7.2中的一个按钮,当我定义.click()函数时,它不会触发事件。 这是我的代码:

describe("after collection loads files", function(){

  beforeEach(function(){
    this.filesColl._processFetchBatchResult(
      constructFetchBatchResult(this.filesAttrs, {IsTruncated:false, Marker:''} ));
      clickFileCheckbox(this.filesTable, 'mySubdir', true); // I click a checkbox in a row
      this.filesTable.$('.tableview-bulk-container button').eq(0).click(); // validates is the subdir is empty and disable bulk actions
  });

  it("validates if the bulk actions are disabled", function(){
    expect(this.filesTable.$(".tableview-bulk-container ul li")            
           .hasClass("disabled")).toBeTruthy(); 

  });
但是当我单击按钮时,它并没有将类“disable”添加到我的按钮中,这在真正的DOM中工作得非常好

我还尝试了.trigger('click')


谢谢。

我对Jasmine不熟悉,但是你的点击处理程序是空的,如果你已经在绑定处理程序的按钮上设置了一个操作,那就好了。因此,您可以尝试以下方法:

this.filesTable.$('.tableview-bulk-container button').eq(0).click(function(){
    //this is where you do stuff, like calling another function
});

希望这有帮助。

这个.filesTable是什么?