问题
modal.hide() is not closing the modal in tests, but works in manual testing. When I check if I can see the modal variable, I can see it from the 'it' statement, so I am not sure why I get a true when it should be false.
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);
});
});
})
});
来源:https://stackoverflow.com/questions/56436437/testing-teaspoon-expected-true-to-equal-false