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

Commit 7291671

Browse files
committed
chore(progressbar): add test
1 parent 8632350 commit 7291671

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/progressbar/progressbar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ angular.module('ui.bootstrap.progressbar', [])
2525
bar.$watch('value', function(value) {
2626
bar.recalculatePercentage();
2727
});
28-
28+
2929
bar.recalculatePercentage = function() {
3030
var totalPercentage = self.bars.reduce(function(total, bar) {
3131
bar.percent = +(100 * bar.value / bar.max).toFixed(2);

src/progressbar/test/progressbar.spec.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,30 @@ describe('progressbar directive', function() {
315315
}
316316
expect(totalWidth.toFixed(2)).toBe('100.00');
317317
});
318+
319+
it('should not have a total width over 100%', function() {
320+
$rootScope.objects = [
321+
{ value: 60, type: 'warning' },
322+
{ value: 103 },
323+
{ value: 270, type: 'info' }
324+
];
325+
$rootScope.max = 433;
326+
$rootScope.$digest();
327+
var totalWidth = 0;
328+
for (var i = 0; i < 3; i++) {
329+
totalWidth += parseFloat(getBar(i).css('width'));
330+
}
331+
expect(totalWidth.toFixed(2)).toBe('100.00');
332+
333+
$rootScope.objects.splice(2, 1);
334+
$rootScope.max = 163;
335+
$rootScope.$digest();
336+
totalWidth = 0;
337+
for (var i = 0; i < 2; i++) {
338+
totalWidth += parseFloat(getBar(i).css('width'));
339+
}
340+
expect(totalWidth.toFixed(2)).toBe('100.00');
341+
});
318342
});
319343
});
320344
});

0 commit comments

Comments
 (0)