feat($ionicModal): add hardwareBackButtonClose as option, default true

Closes #1397
This commit is contained in:
Andrew Joslin
2014-06-04 13:45:21 -06:00
parent 74a4612210
commit 9ffca1e4eb
4 changed files with 36 additions and 8 deletions

View File

@@ -86,7 +86,7 @@ describe('Ionic Modal', function() {
expect(instance.scope.$destroy).toHaveBeenCalled();
}));
it('Should close on hardware back button', inject(function($ionicPlatform) {
it('Should close on hardware back button by default', inject(function($ionicPlatform) {
var template = '<div class="modal"></div>';
var instance = modal.fromTemplate(template);
spyOn($ionicPlatform, 'registerBackButtonAction').andCallThrough();
@@ -101,6 +101,27 @@ describe('Ionic Modal', function() {
expect(instance.isShown()).toBe(false);
}));
it('should not close on hardware back button if option', inject(function($ionicPlatform) {
var template = '<div class="modal"></div>';
var instance = modal.fromTemplate(template, {
hardwareBackButtonClose: false
});
spyOn($ionicPlatform, 'registerBackButtonAction');
instance.show();
timeout.flush();
expect($ionicPlatform.registerBackButtonAction).not.toHaveBeenCalled();
}));
it('should call _deregisterBackButton on hide', function() {
var template = '<div class="modal"></div>';
var instance = modal.fromTemplate(template);
instance.show();
timeout.flush();
spyOn(instance, '_deregisterBackButton');
instance.hide();
expect(instance._deregisterBackButton).toHaveBeenCalled();
});
it('should close modal on backdrop click after animate is done', function() {
var template = '<div class="modal"></div>';
var instance = modal.fromTemplate(template);