茶匙测试,更好的解决方案然后延迟?

时间:2019-06-04 18:16:37

标签: teaspoon

与此问题相关: Testing Teaspoon: Expected true to equal false

我需要增加延迟才能使我的匹配器正常工作。有没有更好的解决方案呢?

茶匙/茉莉花:

describe("Check hide function", function(){
    beforeAll(function(){
        fixture.each("<body></body>");
        timerCallback = jasmine.createSpy("timerCallback");
        jasmine.clock().install();
        modal =  new Helpers.Bootstrap.Modal("#MyCustomModal");
        modal.show('Hide Function','Checking Hide Function','save','cancel', null);
    });

    afterAll(function(){
        jasmine.clock().uninstall();
    });

  it("should close the modal", function(){
        setTimeout(function() {modal.hide()}, 1); 
        jasmine.clock().tick(2);
    var modal_hide =  ($(modal.element).data('bs.modal') || {isShown: false})._isShown;
        expect(modal_hide).toEqual(false);
  });
})

来源:

hide() {
      $(this.element).modal('hide');
    }

0 个答案:

没有答案