Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
test(modal): added unit tests for aside and modal z-index values
Browse files Browse the repository at this point in the history
  • Loading branch information
Dale Alexander Webb authored and mgcrea committed Nov 11, 2015
1 parent abedaa4 commit 37afd3b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
22 changes: 22 additions & 0 deletions src/aside/test/aside.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,28 @@ describe('aside', function () {
expect(bodyEl.find('.aside-backdrop').length).toBe(0);
});

it('should show backdrop above a previous aside dialog using the z-index value', function() {
var elm1 = compileDirective('default');
var elm2 = compileDirective('default');

expect(bodyEl.find('.aside-backdrop').length).toBe(0);

angular.element(elm1[0]).triggerHandler('click');
expect(bodyEl.find('.aside-backdrop').length).toBe(1);
var backdrop1 = bodyEl.find('.aside-backdrop')[0];
var aside1 = bodyEl.find('.aside')[0];

angular.element(elm2[0]).triggerHandler('click');
expect(bodyEl.find('.aside-backdrop').length).toBe(2);
var backdrop2 = bodyEl.find('.aside-backdrop')[0];
var aside2 = bodyEl.find('.aside')[1];

expect(angular.element(backdrop1).css('z-index')).toBe('1040');
expect(angular.element(aside1).css('z-index')).toBe('1050');
expect(angular.element(backdrop2).css('z-index')).toBe('1060');
expect(angular.element(aside2).css('z-index')).toBe('1070');
});

});

describe('keyboard', function() {
Expand Down
6 changes: 4 additions & 2 deletions src/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,10 @@ angular.module('mgcrea.ngStrap.modal', ['mgcrea.ngStrap.core', 'mgcrea.ngStrap.h
$modal.hide = function() {
if(!$modal.$isShown) return;

// decrement number of modals
backdropCount--;
if(options.backdrop) {
// decrement number of modals
backdropCount--;
}

if(scope.$emit(options.prefixEvent + '.hide.before', $modal).defaultPrevented) {
return;
Expand Down
22 changes: 22 additions & 0 deletions src/modal/test/modal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,28 @@ describe('modal', function() {
expect(bodyEl.find('.modal-backdrop').length).toBe(0);
});

it('should show backdrop above a previous modal dialog using the z-index value', function() {
var elm1 = compileDirective('default');
var elm2 = compileDirective('default');

expect(bodyEl.find('.modal-backdrop').length).toBe(0);

angular.element(elm1[0]).triggerHandler('click');
expect(bodyEl.find('.modal-backdrop').length).toBe(1);
var backdrop1 = bodyEl.find('.modal-backdrop')[0];
var modal1 = bodyEl.find('.modal')[0];

angular.element(elm2[0]).triggerHandler('click');
expect(bodyEl.find('.modal-backdrop').length).toBe(2);
var backdrop2 = bodyEl.find('.modal-backdrop')[0];
var modal2 = bodyEl.find('.modal')[1];

expect(angular.element(backdrop1).css('z-index')).toBe('1040');
expect(angular.element(modal1).css('z-index')).toBe('1050');
expect(angular.element(backdrop2).css('z-index')).toBe('1060');
expect(angular.element(modal2).css('z-index')).toBe('1070');
});

});


Expand Down

0 comments on commit 37afd3b

Please sign in to comment.