File tree 2 files changed +30
-1
lines changed
2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,30 @@ describe('ng-progressbar', () => {
120
120
} ) ;
121
121
} ) ) ) ;
122
122
123
+ it ( 'accepts animated as boolean attr' , async ( inject ( [ TestComponentBuilder ] , ( tcb ) => {
124
+ const html = '<ngb-progressbar [value]="value" animated></ngb-progressbar>' ;
125
+
126
+ tcb . overrideTemplate ( TestComponent , html ) . createAsync ( TestComponent ) . then ( ( fixture ) => {
127
+ fixture . detectChanges ( ) ;
128
+
129
+ expect ( getProgressbar ( fixture . nativeElement ) ) . toHaveCssClass ( 'progress-animated' ) ;
130
+ } ) ;
131
+ } ) ) ) ;
132
+
133
+ it ( 'accepts animated as normal attr' , async ( inject ( [ TestComponentBuilder ] , ( tcb ) => {
134
+ const html = '<ngb-progressbar [value]="value" [animated]="animated"></ngb-progressbar>' ;
135
+
136
+ tcb . overrideTemplate ( TestComponent , html ) . createAsync ( TestComponent ) . then ( ( fixture ) => {
137
+ fixture . detectChanges ( ) ;
138
+
139
+ expect ( getProgressbar ( fixture . nativeElement ) ) . toHaveCssClass ( 'progress-animated' ) ;
140
+
141
+ fixture . componentInstance . animated = false ;
142
+ fixture . detectChanges ( ) ;
143
+ expect ( getProgressbar ( fixture . nativeElement ) ) . not . toHaveCssClass ( 'progress-animated' ) ;
144
+ } ) ;
145
+ } ) ) ) ;
146
+
123
147
it ( 'accepts striped as boolean attr' , async ( inject ( [ TestComponentBuilder ] , ( tcb ) => {
124
148
const html = '<ngb-progressbar [value]="value" striped></ngb-progressbar>' ;
125
149
@@ -150,6 +174,7 @@ describe('ng-progressbar', () => {
150
174
class TestComponent {
151
175
value = 10 ;
152
176
max = 50 ;
177
+ animated = true ;
153
178
striped = true ;
154
179
type = 'warning' ;
155
180
}
Original file line number Diff line number Diff line change @@ -5,7 +5,8 @@ import {getValueInRange, toBoolean} from '../util/util';
5
5
selector : 'ngb-progressbar' ,
6
6
changeDetection : ChangeDetectionStrategy . OnPush ,
7
7
template : `
8
- <progress class="progress {{isStriped() && 'progress-striped'}} {{type && 'progress-' + type}}" [value]="getValue()" [max]="max">
8
+ <progress class="progress {{isAnimated() && 'progress-animated'}} {{isStriped() && 'progress-striped'}} {{type && 'progress-' + type}}"
9
+ [value]="getValue()" [max]="max">
9
10
<div class="progress">
10
11
<span class="progress-bar" [style.width.%]="getPercentValue()"><ng-content></ng-content></span>
11
12
</div>
@@ -14,10 +15,13 @@ import {getValueInRange, toBoolean} from '../util/util';
14
15
} )
15
16
export class NgbProgressbar {
16
17
@Input ( ) max : number = 100 ;
18
+ @Input ( ) animated : boolean | string ;
17
19
@Input ( ) striped : boolean | string ;
18
20
@Input ( ) type : string ;
19
21
@Input ( ) value : number ;
20
22
23
+ isAnimated ( ) : boolean { return toBoolean ( this . animated ) ; }
24
+
21
25
isStriped ( ) : boolean { return toBoolean ( this . striped ) ; }
22
26
23
27
getValue ( ) { return getValueInRange ( this . value , this . max ) ; }
You can’t perform that action at this time.
0 commit comments