mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 15:07:13 +08:00
Updating tests, fixing some old toggle and tab stuff
This commit is contained in:
6
js/ext/angular/src/directive/ionicTabBar.js
vendored
6
js/ext/angular/src/directive/ionicTabBar.js
vendored
@ -15,7 +15,7 @@ angular.module('ionic.ui.tabs', ['ngAnimate'])
|
||||
|
||||
this.add = function(controller) {
|
||||
this.addController(controller);
|
||||
this.select(0);
|
||||
this.select(0);
|
||||
};
|
||||
|
||||
this.select = function(controllerIndex) {
|
||||
@ -130,13 +130,15 @@ angular.module('ionic.ui.tabs', ['ngAnimate'])
|
||||
index: '='
|
||||
},
|
||||
link: function(scope, element, attrs, tabsCtrl) {
|
||||
if(attrs.icon) {
|
||||
scope.iconOn = scope.iconOff = attrs.icon;
|
||||
}
|
||||
scope.selectTab = function(index) {
|
||||
tabsCtrl.select(scope.index);
|
||||
};
|
||||
},
|
||||
template:
|
||||
'<a href="#" ng-class="{active:active}" ng-click="selectTab()" class="tab-item">' +
|
||||
'<i class="{{icon}}" ng-if="icon"></i>' +
|
||||
'<i class="{{iconOn}}" ng-if="active"></i>' +
|
||||
'<i class="{{iconOff}}" ng-if="!active"></i> {{title}}' +
|
||||
'</a>'
|
||||
|
||||
2
js/ext/angular/src/directive/ionicToggle.js
vendored
2
js/ext/angular/src/directive/ionicToggle.js
vendored
@ -16,7 +16,7 @@ angular.module('ionic.ui.toggle', [])
|
||||
if(!ngModel) { return; }
|
||||
|
||||
checkbox = $element.children().eq(0);
|
||||
handle = track.children().eq(0);
|
||||
handle = $element.children().eq(1);
|
||||
|
||||
if(!checkbox.length || !handle.length) { return; }
|
||||
|
||||
|
||||
@ -1,24 +1,24 @@
|
||||
describe('Tab Bar Controller', function() {
|
||||
var compile, element, scope, ctrl;
|
||||
|
||||
beforeEach(module('ionic.ui.tabbar'));
|
||||
beforeEach(module('ionic.ui.tabs'));
|
||||
|
||||
beforeEach(inject(function($compile, $rootScope, $controller) {
|
||||
compile = $compile;
|
||||
scope = $rootScope;
|
||||
ctrl = $controller('TabBarCtrl', { $scope: scope, $element: null });
|
||||
ctrl = $controller('TabsCtrl', { $scope: scope, $element: null });
|
||||
}));
|
||||
|
||||
it('Select item in controller works', function() {
|
||||
ctrl.selectTabAtIndex(1);
|
||||
expect(ctrl.getSelectedTabIndex()).toEqual(1);
|
||||
ctrl.selectController(1);
|
||||
expect(ctrl.getSelectedControllerIndex()).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Tab Bar directive', function() {
|
||||
var compile, element, scope;
|
||||
|
||||
beforeEach(module('ionic.ui.tabbar'));
|
||||
beforeEach(module('ionic.ui.tabs'));
|
||||
|
||||
beforeEach(inject(function($compile, $rootScope) {
|
||||
compile = $compile;
|
||||
@ -34,7 +34,7 @@ describe('Tab Bar directive', function() {
|
||||
describe('Tabs directive', function() {
|
||||
var compile, element, scope;
|
||||
|
||||
beforeEach(module('ionic.ui.tabbar'));
|
||||
beforeEach(module('ionic.ui.tabs'));
|
||||
|
||||
beforeEach(inject(function($compile, $rootScope) {
|
||||
compile = $compile;
|
||||
@ -42,10 +42,10 @@ describe('Tabs directive', function() {
|
||||
}));
|
||||
|
||||
it('Has tab class', function() {
|
||||
element = compile('<tab-bar><tabs></tabs></tab-bar>')(scope);
|
||||
element = compile('<tabs></tabs>')(scope);
|
||||
scope.$digest();
|
||||
console.log(element);
|
||||
expect(element.find('.bar').hasClass('bar-tabs')).toBe(true);
|
||||
expect(element.find('.tabs').hasClass('tabs')).toBe(true);
|
||||
});
|
||||
|
||||
it('Has tab children', function() {
|
||||
@ -54,7 +54,7 @@ describe('Tabs directive', function() {
|
||||
{ text: 'Fun', icon: 'icon-fun' },
|
||||
{ text: 'Beer', icon: 'icon-beer' },
|
||||
];
|
||||
element = compile('<tab-bar><tabs></tabs></tab-bar>')(scope);
|
||||
element = compile('<tabs></tabs>')(scope);
|
||||
scope.$digest();
|
||||
expect(element.find('li').length).toBe(3);
|
||||
});
|
||||
@ -63,16 +63,15 @@ describe('Tabs directive', function() {
|
||||
describe('Tab Item directive', function() {
|
||||
var compile, element, scope, ctrl;
|
||||
|
||||
beforeEach(module('ionic.ui.tabbar'));
|
||||
beforeEach(module('ionic.ui.tabs'));
|
||||
|
||||
beforeEach(inject(function($compile, $rootScope, $controller) {
|
||||
compile = $compile;
|
||||
scope = $rootScope;
|
||||
//ctrl = $controller('TabBarCtrl', { $scope: scope, $element: null });
|
||||
|
||||
element = compile('<tab-bar><tabs>' +
|
||||
'<tab-item active="true" text="Item" icon="icon-default"></tab-item>' +
|
||||
'</tabs></tab-bar>')(scope);
|
||||
element = compile('<tabs>' +
|
||||
'<tab active="true" text="Item" icon="icon-default"></tab>' +
|
||||
'</tabs>')(scope);
|
||||
scope.$digest();
|
||||
}));
|
||||
|
||||
@ -85,10 +84,11 @@ describe('Tab Item directive', function() {
|
||||
});
|
||||
|
||||
it('Click sets correct tab index', function() {
|
||||
var a = element.find('a:eq(2)');
|
||||
var a = element.find('a:eq(0)');
|
||||
var itemScope = a.scope();
|
||||
//spyOn(a, 'click');
|
||||
spyOn(scope, 'selectTab');
|
||||
spyOn(itemScope, 'selectTab');
|
||||
a.click();
|
||||
expect(scope.selectTab).toHaveBeenCalled();
|
||||
expect(itemScope.selectTab).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@ -11,7 +11,6 @@ describe('Ionic Toggle', function() {
|
||||
var toggleView = el.scope().toggle;
|
||||
expect(toggleView).not.toEqual(null);
|
||||
expect(toggleView.checkbox).not.toEqual(null);
|
||||
expect(toggleView.track).not.toEqual(null);
|
||||
expect(toggleView.handle).not.toEqual(null);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user