Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
chore(progressbar): switch deprecation warnings
Browse files Browse the repository at this point in the history
Closes #4366
  • Loading branch information
Foxandxss authored and wesleycho committed Sep 7, 2015
1 parent 508aceb commit 50ebfc3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/progressbar/progressbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ angular.module('ui.bootstrap.progressbar', [])
},
templateUrl: 'template/progressbar/progress.html',
link: function() {
if ($progressSuppressWarning) {
if (!$progressSuppressWarning) {
$log.warn('progress is now deprecated. Use uib-progress instead');
}
}
Expand Down Expand Up @@ -119,7 +119,7 @@ angular.module('ui.bootstrap.progressbar', [])
},
templateUrl: 'template/progressbar/bar.html',
link: function(scope, element, attrs, progressCtrl) {
if ($progressSuppressWarning) {
if (!$progressSuppressWarning) {
$log.warn('bar is now deprecated. Use uib-bar instead');
}
progressCtrl.addBar(scope, element);
Expand Down
38 changes: 19 additions & 19 deletions src/progressbar/test/progressbar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,6 @@ describe('progressbar directive', function() {
beforeEach(module('ui.bootstrap.progressbar'));
beforeEach(module('template/progressbar/progress.html', 'template/progressbar/bar.html'));

it('should give warning', inject(function($compile, $log, $rootScope) {
spyOn($log, 'warn');

$rootScope.objects = [
{ value: 10, type: 'success' },
{ value: 50, type: 'warning' },
{ value: 20 }
];
var element = $compile('<progress animate="false"><bar ng-repeat="o in objects" value="o.value" type="{{o.type}}">{{o.value}}</bar></progress>')($rootScope);
$rootScope.$digest();

expect($log.warn.calls.count()).toBe(0);
}));

it('should suppress warning', function() {
module(function($provide) {
$provide.value('$progressSuppressWarning', true);
Expand All @@ -33,13 +19,27 @@ describe('progressbar directive', function() {
var element = $compile('<progress animate="false"><bar ng-repeat="o in objects" value="o.value" type="{{o.type}}">{{o.value}}</bar></progress>')($rootScope);
$rootScope.$digest();

expect($log.warn.calls.count()).toBe(4);
expect($log.warn.calls.argsFor(0)).toEqual(['progress is now deprecated. Use uib-progress instead']);
expect($log.warn.calls.argsFor(1)).toEqual(['bar is now deprecated. Use uib-bar instead']);
expect($log.warn.calls.argsFor(2)).toEqual(['bar is now deprecated. Use uib-bar instead']);
expect($log.warn.calls.argsFor(3)).toEqual(['bar is now deprecated. Use uib-bar instead']);
expect($log.warn.calls.count()).toBe(0);
});
});

it('should give warning by default', inject(function($compile, $log, $rootScope) {
spyOn($log, 'warn');

$rootScope.objects = [
{ value: 10, type: 'success' },
{ value: 50, type: 'warning' },
{ value: 20 }
];
var element = $compile('<progress animate="false"><bar ng-repeat="o in objects" value="o.value" type="{{o.type}}">{{o.value}}</bar></progress>')($rootScope);
$rootScope.$digest();

expect($log.warn.calls.count()).toBe(4);
expect($log.warn.calls.argsFor(0)).toEqual(['progress is now deprecated. Use uib-progress instead']);
expect($log.warn.calls.argsFor(1)).toEqual(['bar is now deprecated. Use uib-bar instead']);
expect($log.warn.calls.argsFor(2)).toEqual(['bar is now deprecated. Use uib-bar instead']);
expect($log.warn.calls.argsFor(3)).toEqual(['bar is now deprecated. Use uib-bar instead']);
}));
});
});

Expand Down

0 comments on commit 50ebfc3

Please sign in to comment.