feat(platforms): Android and iOS Specific Styles and Transitions

This commit is contained in:
Max Lynch
2014-06-11 16:48:53 -05:00
parent 8476f0cb3a
commit c30be67f65
19 changed files with 823 additions and 107 deletions

View File

@@ -92,7 +92,8 @@ describe('bar directives', function() {
function setup(attrs) {
var el;
ionic.views.HeaderBar = function(opts) {
this.opts = opts;
this.alignTitle = opts.alignTitle;
this.el = opts.el;
this.align = jasmine.createSpy('align');
};
inject(function($compile, $rootScope) {

View File

@@ -1,3 +1,4 @@
describe('ionNavBackButton directive', function() {
beforeEach(module('ionic'));
@@ -76,4 +77,29 @@ describe('ionNavBackButton directive', function() {
expect(el.scope().$navBack).not.toHaveBeenCalled();
expect(el.scope().doSomething).toHaveBeenCalled();
});
describe('ionNavBackButton directive: Platforms', function() {
describe('ionNavBackButton directive: iOS Platform', function() {
beforeEach(function($provide) {
TestUtil.setPlatform('ios');
});
it('Should set default back button icon from ionicNavBarConfig ', inject(function($ionicNavBarConfig) {
var el = setup();
expect(el.hasClass('ion-ios7-arrow-back')).toBe(true);
}));
});
describe('ionNavBackButton directive: Android Platform', function() {
beforeEach(function($provide) {
TestUtil.setPlatform('android');
});
it('Should set default back button icon from ionicNavBarConfig ', inject(function($ionicNavBarConfig) {
var el = setup();
expect(el.hasClass('ion-android-arrow-back')).toBe(true);
}));
});
});
});

View File

@@ -294,4 +294,60 @@ describe('ionNavBar', function() {
expect(el.hasClass('reverse')).toBe(false);
});
});
describe('platforms', function() {
function setup(attrs, content) {
var el;
inject(function($compile, $rootScope) {
el = $compile('<ion-nav-bar '+(attrs||'')+'>'+(content||'')+'</ion-nav-bar>')($rootScope.$new());
$rootScope.$apply();
});
return el;
}
describe('iOS', function() {
beforeEach(module('ionic', function($provide) {
TestUtil.setPlatform('ios');
$provide.constant('$ionicNavBarConfig', {
alignTitle: 'center',
transition: 'nav-title-slide-ios7',
backButtonIcon: 'ion-ios7-arrow-back'
});
}));
it('should have correct title align', function() {
var el = setup();
var controller = el.controller('ionNavBar');
expect(controller._headerBarView.alignTitle).toBe('center');
});
it('Should have correct transition', function() {
var el = setup();
expect(el.hasClass('nav-title-slide-ios7')).toBe(true);
});
});
describe('Android', function() {
beforeEach(module('ionic', function($provide) {
TestUtil.setPlatform('android');
$provide.constant('$ionicNavBarConfig', {
alignTitle: 'left',
transition: 'no-animation',
backButtonIcon: 'ion-android-back'
});
}));
it('should have correct title align', function() {
var el = setup();
var controller = el.controller('ionNavBar');
expect(controller._headerBarView.alignTitle).toBe('left');
});
it('Should have correct transition', function() {
var el = setup();
// Nav bar titles don't animation by default on Android
expect(el.hasClass('no-animation')).toBe(true);
});
});
});
});

View File

@@ -260,6 +260,35 @@ describe('tabs', function() {
var el = setup('', '<div class="content"></div>');
expect(el[0].querySelector('.tabs .content')).toBeTruthy();
});
describe('platform Styles', function() {
describe('iOS', function() {
beforeEach(module('ionic', function($provide) {
TestUtil.setPlatform('ios');
$provide.constant('$ionicTabsConfig', {
type: ''
});
}));
it('should set iOS style', function() {
var el = setup();
expect(el.hasClass('tabs-striped')).not.toBe(true);
});
});
describe('android', function() {
beforeEach(module('ionic', function($provide) {
TestUtil.setPlatform('android');
$provide.constant('$ionicTabsConfig', {
type: 'tabs-striped'
});
}));
it('should set Android style', function() {
var el = setup();
expect(el.hasClass('tabs-striped')).toBe(true);
});
});
});
});
describe('ionicTab controller', function() {