Correct nested directives and shared scope thing

This commit is contained in:
Max Lynch
2013-09-05 11:04:59 -05:00
parent 4f7e87bfcc
commit f62000254d
3 changed files with 47 additions and 24 deletions

View File

@ -1,5 +1,5 @@
describe('Tab Bar Controller', function() {
var compile, element, scope;
var compile, element, scope, ctrl;
beforeEach(module('ionic.ui.tabbar'));
@ -20,8 +20,6 @@ describe('Tab Bar directive', function() {
beforeEach(module('ionic.ui.tabbar'));
//beforeEach(module('ext/angular/tmpl/ionicTabBar.tmpl.html', 'ext/angular/tmpl/ionicTabs.tmpl.html'));
beforeEach(inject(function($compile, $rootScope) {
compile = $compile;
scope = $rootScope;
@ -29,7 +27,7 @@ describe('Tab Bar directive', function() {
it('Has section wrapper class', function() {
element = compile('<tab-bar></tab-bar>')(scope);
expect(element.hasClass('full-section')).toBe(true);
expect(element.hasClass('view-wrapper')).toBe(true);
});
});
@ -44,8 +42,10 @@ describe('Tabs directive', function() {
}));
it('Has tab class', function() {
element = compile('<tabs></tabs>')(scope);
expect(element.hasClass('bar-tabs')).toBe(true);
element = compile('<tab-bar><tabs></tabs></tab-bar>')(scope);
scope.$digest();
console.log(element);
expect(element.find('.bar').hasClass('bar-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('<tabs></tabs>')(scope);
element = compile('<tab-bar><tabs></tabs></tab-bar>')(scope);
scope.$digest();
expect(element.find('li').length).toBe(3);
});
@ -65,20 +65,29 @@ describe('Tab Item directive', function() {
beforeEach(module('ionic.ui.tabbar'));
beforeEach(inject(function($compile, $rootScope) {
beforeEach(inject(function($compile, $rootScope, $controller) {
compile = $compile;
scope = $rootScope;
scope.tabs = [
{ text: 'Home', icon: 'icon-home' },
{ text: 'Fun', icon: 'icon-fun' },
{ text: 'Beer', icon: 'icon-beer' },
];
element = compile('<tab-bar><tabs><tab-item></tab-item></tabs></tab-bar>')(scope);
scope.$digest();
}));
it('Default text works', function() {
element = compile('<tab-item></tab-item>')(scope);
scope.$digest();
expect(element.find('a').text()).toEqual('Item');
expect(element.find('a').first().text()).toEqual('Item');
});
it('Default icon works', function() {
element = compile('<tab-item></tab-item>')(scope);
scope.$digest();
expect(element.find('i').hasClass('icon-default')).toBeTruthy();
expect(element.find('i').hasClass('icon-default')).toEqual(true);
});
it('Click sets correct tab index', function() {
expect(element.find('i').hasClass('icon-default')).toEqual(true);
});
})