Added Unit Tests and fixed attribute bug

This commit is contained in:
Dale Cameron
2020-10-07 23:53:33 -05:00
parent 01907c07fb
commit 5823072290
2 changed files with 26 additions and 2 deletions
+3 -2
View File
@@ -102,7 +102,7 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.multiMap', 'ui.bootstrap.sta
link: function(scope, element, attrs) {
element.addClass(attrs.windowTopClass || '');
scope.size = attrs.size;
scope.scrollable = attrs.scrollable;
scope.scrollable = attrs.scrollable === 'true';
scope.close = function(evt) {
var modal = $modalStack.getTop();
@@ -426,7 +426,8 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.multiMap', 'ui.bootstrap.sta
openedClass: modal.openedClass,
windowTopClass: modal.windowTopClass,
animation: modal.animation,
appendTo: modal.appendTo
appendTo: modal.appendTo,
scrollable: modal.scrollable
});
openedClasses.put(modalBodyClass, modalInstance);
+23
View File
@@ -1389,6 +1389,29 @@ describe('$uibModal', function() {
});
});
describe('scrollable', function() {
it('should default to false', function() {
open({
template: '<div>Non scollable modal dialog</div>'
});
expect($document.find('div.modal-dialog')).not.toHaveClass('modal-dialog-scrollable');
});
it('should add the scrollable class if scrollable set to true', function() {
open({
template: '<div>Large modal dialog</div>',
scrollable: true
});
expect($document.find('div.modal-dialog')).toHaveClass('modal-dialog-scrollable');
});
it('should allow overriding default options in a provider', function() {
$uibModalProvider.options.scrollable = true;
open({template: '<div>Content</div>'});
expect($document.find('div.modal-dialog')).toHaveClass('modal-dialog-scrollable');
});
});
describe('animation', function() {
it('should have animation fade classes by default', function() {
open({