-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
md-selected
to -1
will allow md-tabs
to fun…
…ction without forcing a tab to be selected Closes #3172
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,11 +36,13 @@ describe('<md-tabs>', function () { | |
}); | ||
}); | ||
|
||
function setup (template) { | ||
function setup (template, scope) { | ||
var el; | ||
inject(function ($compile, $rootScope) { | ||
el = $compile(template)($rootScope.$new()); | ||
$rootScope.$apply(); | ||
newScope = $rootScope.$new(); | ||
for (var key in scope || {}) newScope[key] = scope[key]; | ||
el = $compile(template)(newScope); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
robertmesserle
Contributor
|
||
newScope.$apply(); | ||
}); | ||
return el; | ||
} | ||
|
@@ -287,14 +289,30 @@ describe('<md-tabs>', function () { | |
</md-tab>\ | ||
</md-tabs>\ | ||
'; | ||
var element = setup(template); | ||
var button = element.find('md-button'); | ||
var element = setup(template); | ||
var button = element.find('md-button'); | ||
|
||
expect(button[0 ].tagName).toBe('MD-BUTTON'); | ||
expect(button[ 0 ].tagName).toBe('MD-BUTTON'); | ||
|
||
button.triggerHandler('click'); | ||
|
||
expect(element.scope().data).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('no tab selected', function () { | ||
it('should allow cases where no tabs are selected', inject(function () { | ||
var template = '\ | ||
<md-tabs md-selected="selectedIndex">\ | ||
<md-tab label="a">tab content</md-tab>\ | ||
<md-tab label="b">tab content</md-tab>\ | ||
</md-tabs>\ | ||
'; | ||
var element = setup(template, { selectedIndex: -1 }); | ||
var scope = element.scope(); | ||
|
||
expect(scope.selectedIndex).toBe(-1); | ||
expect(element.find('md-tabs-content-wrapper').hasClass('ng-hide')).toBe(true); | ||
})); | ||
}); | ||
}); |
@robertmesserle - I am pretty certain that here we should be using $mdCompile