1

modal.hide() 不是在测试中关闭模态,而是在手动测试中工作。当我检查是否可以看到模态变量时,我可以从“it”语句中看到它,所以我不确定为什么当它应该为假时我得到一个真。

describe("Helpers.Bootstrap.Modal", function() {
  describe("show", function(){
    var modal ;

    describe("When no element Id is assigned to Modal()", function(){
        beforeAll(function(){
            modal =  new Helpers.Bootstrap.Modal();
            modal.show('Title','Message','ok','close', null);
        })

        it("constructor should return default Id", function(){
            expect(modal.element).toEqual("#AlertModal");
            expect(modal.elementname).toEqual("AlertModal");
        });

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

0 回答 0