refactor($ionicLoading): make sure .hide() always happens after .show()

Fixes #1085.  Thanks @graemefoster.
This commit is contained in:
Andy Joslin
2014-04-09 06:41:43 -06:00
parent d0b47d879f
commit c7d7dab75f
2 changed files with 20 additions and 2 deletions

View File

@@ -103,5 +103,21 @@ describe('$ionicLoading service', function() {
expect(loader.hide).toHaveBeenCalled();
}));
it('hide should happen after show', inject(function($ionicLoading, $timeout) {
ionic.requestAnimationFrame = function(cb) { cb(); };
var loader = TestUtil.unwrapPromise($ionicLoading._getLoader());
spyOn(loader, 'hide').andCallThrough();
spyOn(loader, 'show').andCallThrough();
$ionicLoading.show({ delay: 1000 });
$ionicLoading.hide();
expect(loader.show).not.toHaveBeenCalled();
expect(loader.hide).not.toHaveBeenCalled();
$timeout.flush();
expect(loader.show).toHaveBeenCalled();
expect(loader.hide).toHaveBeenCalled();
expect(loader.isShown).toBe(false);
expect(loader.element.hasClass('ng-hide')).toBe(true);
}));
});
});