Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
fix($dialog): fix $apply in progres on $location change
Browse files Browse the repository at this point in the history
  • Loading branch information
pkozlowski-opensource committed Apr 25, 2013
1 parent 474ce52 commit 77e6acb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
1 change: 0 additions & 1 deletion src/dialog/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ dialogModule.provider("$dialog", function(){

this.handleLocationChange = function() {
self.close();
self.$scope.$apply();
};
}

Expand Down
31 changes: 17 additions & 14 deletions src/dialog/test/dialog.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ describe('Given ui.bootstrap.dialog', function(){
provider.options({});
};

var changeLocation = function() {
$rootScope.$broadcast('$locationChangeSuccess');
$rootScope.$apply();
};

var dialogShouldBeClosed = function(){
it('should not include a backdrop in the DOM', function(){
Expand All @@ -75,7 +71,7 @@ describe('Given ui.bootstrap.dialog', function(){
});

it('should return false for isOpen()', function(){
expect(dialog.isOpen()).toBe(false);
expect(dialog.isOpen()).toBeFalsy();
});
};

Expand Down Expand Up @@ -292,16 +288,23 @@ describe('Given ui.bootstrap.dialog', function(){
expect($document.find('body > div.modal > div.modal-header').length).toBe(1);
});
});

describe('When dialog is open and location changes', function(){
beforeEach(function(){
createDialog({template:template});
openDialog();
changeLocation();
});

dialogShouldBeClosed();
});
describe('When dialog is open and location changes', function () {

var changeLocation = function () {
$rootScope.$apply(function(){
$rootScope.$broadcast('$locationChangeSuccess');
});
};

beforeEach(function () {
createDialog({template: template});
openDialog();
changeLocation();
});

dialogShouldBeClosed();
});

describe('when opening it with a template containing white-space', function(){

Expand Down
11 changes: 6 additions & 5 deletions src/modal/test/modal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,11 @@ describe('Give ui.boostrap.modal', function() {
expect($scope.modalShown).not.toBeTruthy();
});

it('should update the model if the location change is successful', function() {
$rootScope.$broadcast('$locationChangeSuccess');
$scope.$digest();
expect($scope.modalShown).not.toBeTruthy();
});
it('should update the model if the location change is successful', function () {
$rootScope.$apply(function(){
$rootScope.$broadcast('$locationChangeSuccess');
});
expect($scope.modalShown).toBeFalsy();
});
});
});

0 comments on commit 77e6acb

Please sign in to comment.