-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sideMenu): make android back button close side menu
Closes #1264
- Loading branch information
Showing
3 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
describe('$ionicSideMenus controller', function() { | ||
beforeEach(module('ionic')); | ||
|
||
function setup(locals, props) { | ||
var ctrl; | ||
inject(function($controller, $rootScope) { | ||
var scope = $rootScope.$new(); | ||
ctrl = $controller('$ionicSideMenus', angular.extend({ | ||
$scope: scope, | ||
$attrs: {} | ||
}, locals || {})); | ||
angular.extend(ctrl, props || {}); | ||
}); | ||
return ctrl; | ||
} | ||
|
||
it('should register with backButton on open and dereg on close', inject(function($ionicPlatform) { | ||
var openAmount = 0; | ||
var deregSpy = jasmine.createSpy('deregister'); | ||
spyOn($ionicPlatform, 'registerBackButtonAction').andReturn(deregSpy); | ||
|
||
var ctrl = setup(); | ||
spyOn(ctrl, 'getOpenAmount').andCallFake(function() { return openAmount; }); | ||
|
||
expect($ionicPlatform.registerBackButtonAction).not.toHaveBeenCalled(); | ||
openAmount = 1; | ||
ctrl.$scope.$apply(); | ||
expect($ionicPlatform.registerBackButtonAction).toHaveBeenCalledWith( | ||
jasmine.any(Function), | ||
PLATFORM_BACK_BUTTON_PRIORITY_SIDE_MENU | ||
); | ||
expect(deregSpy).not.toHaveBeenCalled(); | ||
openAmount = 0; | ||
ctrl.$scope.$apply(); | ||
expect(deregSpy).toHaveBeenCalled(); | ||
})); | ||
}); |