mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
Addresses #1100. Fixes race conditions where $animate.{removeClass,hideClass} are called simultaneously, in addition fixes any blinking that coulld be caused by showing an element just attached to the dom.
46 lines
1.5 KiB
JavaScript
46 lines
1.5 KiB
JavaScript
describe('$ionicBackdrop service', function() {
|
|
beforeEach(module('ionic'));
|
|
|
|
beforeEach(inject(function($animate) {
|
|
ionic.requestAnimationFrame = function(cb) { cb(); };
|
|
}));
|
|
|
|
it('should remove ngHide on retain', inject(function($ionicBackdrop, $timeout) {
|
|
var el = $ionicBackdrop._element;
|
|
expect(el.hasClass('ng-hide')).toBe(true);
|
|
$ionicBackdrop.retain();
|
|
$timeout.flush();
|
|
expect(el.hasClass('ng-hide')).toBe(false);
|
|
}));
|
|
|
|
it('should add ngHide on retain', inject(function($ionicBackdrop, $timeout) {
|
|
var el = $ionicBackdrop._element;
|
|
expect(el.hasClass('ng-hide')).toBe(true);
|
|
$ionicBackdrop.retain();
|
|
$timeout.flush();
|
|
expect(el.hasClass('ng-hide')).toBe(false);
|
|
$ionicBackdrop.release();
|
|
$timeout.flush();
|
|
expect(el.hasClass('ng-hide')).toBe(true);
|
|
}));
|
|
|
|
it('should require equal releases and retains', inject(function($ionicBackdrop, $timeout) {
|
|
var el = $ionicBackdrop._element;
|
|
expect(el.hasClass('ng-hide')).toBe(true);
|
|
$ionicBackdrop.retain();
|
|
$timeout.flush();
|
|
expect(el.hasClass('ng-hide')).toBe(false);
|
|
$ionicBackdrop.retain();
|
|
expect(el.hasClass('ng-hide')).toBe(false);
|
|
$ionicBackdrop.retain();
|
|
expect(el.hasClass('ng-hide')).toBe(false);
|
|
$ionicBackdrop.release();
|
|
expect(el.hasClass('ng-hide')).toBe(false);
|
|
$ionicBackdrop.release();
|
|
expect(el.hasClass('ng-hide')).toBe(false);
|
|
$ionicBackdrop.release();
|
|
$timeout.flush();
|
|
expect(el.hasClass('ng-hide')).toBe(true);
|
|
}));
|
|
});
|