fix(ionNavButtons): do not append if page is removed very quickly

This commit is contained in:
Andrew Joslin
2014-05-08 08:15:59 -06:00
parent d839f4da64
commit 24a488bbb3
3 changed files with 88 additions and 33 deletions

View File

@@ -1,15 +1,5 @@
describe('ionNavBackButton directive', function() {
beforeEach(module('ionic', function($compileProvider) {
$compileProvider.directive('needsScroll', function() {
return {
//Test if the buttons are 'children of ionScroll' when compiled
require: '^$ionicScroll',
link: function(scope, element, attrs, ctrl) {
element.data('scrollCtrl', ctrl);
}
};
});
}));
beforeEach(module('ionic'));
function setup(attr, content) {
var el;
@@ -24,27 +14,6 @@ describe('ionNavBackButton directive', function() {
return el;
}
it('ionNavButtons should compile buttons with same scope & access the same data on compile', inject(function($compile, $rootScope) {
var el = $compile('<div>' +
'<ion-nav-bar></ion-nav-bar>' +
'<ion-view>' +
'<ion-content>' +
'<ion-nav-buttons side="left">' +
'<button needs-scroll>Hello!</button>' +
'</ion-nav-buttons>' +
'</ion-content>' +
'</ion-view>' +
'</div>')($rootScope.$new());
$rootScope.$apply();
expect(el.find('ion-content').children().scope())
.toBe(el.find('.left-buttons button').scope());
//Test if the button was compiled able to access the parents of ion-nav-buttons
var scrollCtrl = el.find('ion-content').controller('$ionicScroll');
expect(scrollCtrl).toBeTruthy();
expect(el.find('button[needs-scroll]').data('scrollCtrl')).toBe(scrollCtrl);
}));
it('should error without a parent ionNavBar', inject(function($compile, $rootScope) {
expect(function() {
$compile('<ion-nav-back-button>')($rootScope);