mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
feat($ionicModal): add hardwareBackButtonClose as option, default true
Closes #1397
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user