mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
test(ionBar): make tests instant
This commit is contained in:
2
js/ext/angular/src/directive/ionicBar.js
vendored
2
js/ext/angular/src/directive/ionicBar.js
vendored
@@ -50,7 +50,7 @@ angular.module('ionic.ui.header', ['ngAnimate', 'ngSanitize'])
|
||||
* align-title="center">
|
||||
* </ion-header-bar>
|
||||
* ```
|
||||
*
|
||||
*
|
||||
*/
|
||||
.directive('ionHeaderBar', ['$ionicScrollDelegate', function($ionicScrollDelegate) {
|
||||
return {
|
||||
|
||||
@@ -3,60 +3,41 @@ describe('Ionic Header Bar', function() {
|
||||
|
||||
beforeEach(module('ionic'));
|
||||
|
||||
beforeEach(inject(function($compile, $rootScope) {
|
||||
beforeEach(inject(function($animate, $compile, $rootScope) {
|
||||
compile = $compile;
|
||||
rootScope = $rootScope;
|
||||
ionic.requestAnimationFrame = function(cb) { cb(); };
|
||||
$animate.enabled(false);
|
||||
el = null;
|
||||
}));
|
||||
|
||||
it('Should not add title-left or title-right classes when align-title=center', function() {
|
||||
runs(function(){
|
||||
el = compile('<ion-header-bar align-title="center"></ion-header-bar>')(rootScope);
|
||||
});
|
||||
|
||||
//wait for headerBar View to align() the title
|
||||
waits(500);
|
||||
|
||||
runs(function(){
|
||||
var headerView = el.isolateScope().headerBarView;
|
||||
var title = angular.element(headerView.el.querySelector('.title'));
|
||||
expect(title.hasClass('title-left')).not.toEqual(true);
|
||||
expect(title.hasClass('title-right')).not.toEqual(true);
|
||||
});
|
||||
el = compile('<ion-header-bar align-title="center"></ion-header-bar>')(rootScope);
|
||||
var headerView = el.isolateScope().headerBarView;
|
||||
var title = angular.element(headerView.el.querySelector('.title'));
|
||||
expect(title.hasClass('title-left')).not.toEqual(true);
|
||||
expect(title.hasClass('title-right')).not.toEqual(true);
|
||||
});
|
||||
|
||||
it('Should add title-left class when align-title=left', function() {
|
||||
runs(function(){
|
||||
el = compile('<ion-header-bar align-title="left"></ion-header-bar>')(rootScope);
|
||||
});
|
||||
|
||||
//wait for headerBar View to align() the title
|
||||
waits(500);
|
||||
|
||||
runs(function(){
|
||||
var headerView = el.isolateScope().headerBarView;
|
||||
var title = angular.element(headerView.el.querySelector('.title'));
|
||||
expect(title.hasClass('title-left')).toEqual(true);
|
||||
});
|
||||
});
|
||||
it('Should add title-left class when align-title=left', inject(function($animate) {
|
||||
el = compile('<ion-header-bar align-title="left"></ion-header-bar>')(rootScope);
|
||||
rootScope.$apply();
|
||||
var headerView = el.isolateScope().headerBarView;
|
||||
var title = angular.element(headerView.el.querySelector('.title'));
|
||||
expect(title.hasClass('title-left')).toEqual(true);
|
||||
}));
|
||||
|
||||
it('Should add title-right class when align-title=right', function() {
|
||||
runs(function(){
|
||||
el = compile('<ion-header-bar align-title="right"></ion-header-bar>')(rootScope);
|
||||
});
|
||||
|
||||
//wait for headerBar View to align() the title
|
||||
waits(500);
|
||||
|
||||
runs(function(){
|
||||
var headerView = el.isolateScope().headerBarView;
|
||||
var title = angular.element(headerView.el.querySelector('.title'));
|
||||
expect(title.hasClass('title-right')).toEqual(true);
|
||||
});
|
||||
el = compile('<ion-header-bar align-title="right"></ion-header-bar>')(rootScope);
|
||||
rootScope.$apply();
|
||||
var headerView = el.isolateScope().headerBarView;
|
||||
var title = angular.element(headerView.el.querySelector('.title'));
|
||||
expect(title.hasClass('title-right')).toEqual(true);
|
||||
});
|
||||
|
||||
it('Should re-align the title when leftButtons change', function() {
|
||||
rootScope.leftButtons = [];
|
||||
el = compile('<ion-header-bar left-buttons="leftButtons" align-title="right"></ion-header-bar>')(rootScope);
|
||||
el = compile('<ion-header-bar left-buttons="leftButtons" align-title="right"></ion-header-bar>')(rootScope);
|
||||
var headerView = el.isolateScope().headerBarView;
|
||||
|
||||
//trigger initial align()
|
||||
@@ -73,7 +54,7 @@ describe('Ionic Header Bar', function() {
|
||||
|
||||
it('Should re-align the title when rightButtons change', function() {
|
||||
rootScope.rightButtons = [];
|
||||
el = compile('<ion-header-bar right-buttons="rightButtons" align-title="right"></ion-header-bar>')(rootScope);
|
||||
el = compile('<ion-header-bar right-buttons="rightButtons" align-title="right"></ion-header-bar>')(rootScope);
|
||||
var headerView = el.isolateScope().headerBarView;
|
||||
|
||||
//trigger initial align()
|
||||
@@ -88,6 +69,6 @@ describe('Ionic Header Bar', function() {
|
||||
expect(headerView.align).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user