Skip to content
Snippets Groups Projects
Commit 7e5c9bec authored by Radoslav Petkov's avatar Radoslav Petkov
Browse files

Change shown event to use bootbox init and add bootstrap transition since it...

Change shown event to use bootbox init and add bootstrap transition since it is required for modal.js to work properly
Add proper unit test to assert if init is called
parent ea2a0a53
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,7 @@ module.exports = function(grunt) {
'node_modules/jquery-migrate/dist/jquery-migrate.min.js',
'node_modules/jquery-ui-dist/jquery-ui.min.js',
'node_modules/bootstrap/js/modal.js',
'node_modules/bootstrap/js/transition.js',
'node_modules/bootbox/bootbox.js',
'node_modules/jquery.scrollto/jquery.scrollTo.min.js',
'js/lib/jquery.qtip.min.js',
......
......
......@@ -16,7 +16,7 @@
},
_attachEvents:function(el){
var _this = this;
jQuery(el).on("shown.bs.modal",function(){
el.init(function(){
// set bigger z-index that one used in qtip
var zIndex = 20000;
......@@ -24,7 +24,7 @@
// workaround because bootstap does not support external configuration for backdrop parent
jQuery('.modal-backdrop').prependTo(_this.container).css('z-index',zIndex);
});
jQuery(el).on("hidden.bs.modal",function(){
jQuery(el).on('hidden.bs.modal',function(){
jQuery('.modal-backdrop').remove();
});
}
......
......
......@@ -3,8 +3,12 @@ describe('Dialog Builder', function () {
beforeEach(function () {
// stub bootbox.js ( DialogBuilder is wrapper)
bootbox = jasmine.createSpy();
bootbox.confirm = jasmine.createSpy();
bootbox.dialog = jasmine.createSpy();
var self = this;
self.initSpy = jasmine.createSpyObj('initSpy', ['init']);
bootbox.confirm = jasmine.createSpy('confirm').and.returnValue(self.initSpy);
bootbox.dialog = jasmine.createSpy().and.returnValue(self.initSpy);
bootbox.setDefaults = jasmine.createSpy();
this.dialogBuilder = new Mirador.DialogBuilder();
......@@ -15,15 +19,20 @@ describe('Dialog Builder', function () {
});
it('should call underlying confirm method', function () {
var onConfirm = function(){};
var onConfirm = function () {
};
this.initSpy.init.calls.reset();
this.dialogBuilder.confirm('msg', onConfirm);
expect(bootbox.confirm).toHaveBeenCalledWith('msg', onConfirm);
expect(this.initSpy.init).toHaveBeenCalled();
});
it('should call underlying dialog method', function () {
var opts = {};
this.initSpy.init.calls.reset();
this.dialogBuilder.dialog(opts);
expect(bootbox.dialog).toHaveBeenCalledWith(opts);
expect(this.initSpy.init).toHaveBeenCalled();
})
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment