Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
test(toolbar): Fix failing unit tests in 1.3.x.
Browse files Browse the repository at this point in the history
In Angular 1.3.20/19, some of the toolbar unit tests fail due to
not properly calling `$timeout.flush()` within the test.

Add the proper timeout flush to the tests.

  Closes #6550
  • Loading branch information
topherfangio authored and ThomasBurleson committed Jan 18, 2016
1 parent 0e334cd commit 1b7b557
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/toolbar/toolbar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe('<md-toolbar>', function() {
expect(element.find('md-toolbar').length).toBe(0);
}));

it('works with ng-show', inject(function($$rAF) {
it('works with ng-show', inject(function($$rAF, $timeout) {
var template =
'<div layout="column" style="height: 600px;">' +
' <md-toolbar md-scroll-shrink="true" ng-show="shouldShowToolbar">test</md-toolbar>' +
Expand Down Expand Up @@ -154,6 +154,7 @@ describe('<md-toolbar>', function() {
// Show the toolbar and ensure it is visible
pageScope.$apply('shouldShowToolbar = true');
pageScope.$digest();
$timeout.flush();

toolbarStyles = getComputedStyle(element.find('md-toolbar')[0]);
contentStyles = getComputedStyle(element.find('md-content')[0]);
Expand All @@ -170,7 +171,7 @@ describe('<md-toolbar>', function() {
document.body.removeChild(element[0]);
}));

it('works with ng-hide', inject(function($$rAF) {
it('works with ng-hide', inject(function($$rAF, $timeout) {
var template =
'<div layout="column" style="height: 600px;">' +
' <md-toolbar md-scroll-shrink="true" ng-hide="shouldNotShowToolbar">test</md-toolbar>' +
Expand Down Expand Up @@ -206,6 +207,7 @@ describe('<md-toolbar>', function() {
// Show the toolbar and ensure it is hidden
pageScope.$apply('shouldNotShowToolbar = true');
pageScope.$digest();
$timeout.flush();

toolbarStyles = getComputedStyle(element.find('md-toolbar')[0]);
contentStyles = getComputedStyle(element.find('md-content')[0]);
Expand Down

0 comments on commit 1b7b557

Please sign in to comment.