Fixed #40 with test

This commit is contained in:
Max Lynch
2013-10-29 14:27:54 -05:00
parent 01bbf5c1fa
commit 082259dcfb
7 changed files with 65 additions and 8 deletions

View File

@ -36,6 +36,28 @@ describe('Tab Bar Controller', function() {
expect(ctrl.getSelectedControllerIndex()).toEqual(1);
});
it('Calls change callback', function() {
scope.onControllerChanged = function(oldC, oldI, newC, newI) {
};
// Add a controller
ctrl.add({
title: 'Cats',
icon: 'icon-kitty-kat'
});
ctrl.add({
title: 'Dogs',
icon: 'icon-rufus'
});
spyOn(ctrl, 'controllerChanged');
expect(ctrl.getSelectedControllerIndex()).toEqual(0);
ctrl.select(1);
expect(ctrl.controllerChanged).toHaveBeenCalled();
});
});
describe('Tab Bar directive', function() {

View File

@ -47,8 +47,8 @@
}
</style>
</head>
<body>
<tabs animation="fade-in-out">
<body ng-controller="RootCtrl">
<tabs animation="fade-in-out" controller-changed="onControllerChanged(oldController, oldIndex, newController, newIndex)">
<tab title="Home" icon-on="icon-ios7-filing" icon-off="icon-ios7-filing-outline" ng-controller="HomeCtrl">
<header class="bar bar-header bar-secondary">
@ -111,6 +111,14 @@
<script>
angular.module('tabsTest', ['ionic.ui', 'ionic.service.modal', 'ionic.service.actionSheet'])
.controller('RootCtrl', function($scope) {
$scope.onControllerChanged = function(oldController, oldIndex, newController, newIndex) {
console.log('Controller changed', oldController, oldIndex, newController, newIndex);
console.log(arguments);
};
})
.controller('HomeCtrl', function($scope, Modal, ActionSheet) {
$scope.items = [];