@@ -2,7 +2,6 @@ import {TestBed, async} from '@angular/core/testing';
2
2
import { Component } from '@angular/core' ;
3
3
import { By } from '@angular/platform-browser' ;
4
4
import { MdProgressSpinnerModule } from './index' ;
5
- import { PROGRESS_SPINNER_STROKE_WIDTH } from './progress-spinner' ;
6
5
7
6
8
7
describe ( 'MdProgressSpinner' , ( ) => {
@@ -16,13 +15,9 @@ describe('MdProgressSpinner', () => {
16
15
ProgressSpinnerWithValueAndBoundMode ,
17
16
ProgressSpinnerWithColor ,
18
17
ProgressSpinnerCustomStrokeWidth ,
19
- IndeterminateProgressSpinnerWithNgIf ,
20
- SpinnerWithNgIf ,
21
- SpinnerWithColor
18
+ SpinnerWithColor ,
22
19
] ,
23
- } ) ;
24
-
25
- TestBed . compileComponents ( ) ;
20
+ } ) . compileComponents ( ) ;
26
21
} ) ) ;
27
22
28
23
it ( 'should apply a mode of "determinate" if no mode is provided.' , ( ) => {
@@ -84,51 +79,37 @@ describe('MdProgressSpinner', () => {
84
79
expect ( progressComponent . value ) . toBe ( 0 ) ;
85
80
} ) ;
86
81
87
- it ( 'should clean up the indeterminate animation when the element is destroyed' , ( ) => {
88
- let fixture = TestBed . createComponent ( IndeterminateProgressSpinnerWithNgIf ) ;
89
- fixture . detectChanges ( ) ;
90
-
91
- let progressElement = fixture . debugElement . query ( By . css ( 'md-progress-spinner' ) ) ;
92
- expect ( progressElement . componentInstance . interdeterminateInterval ) . toBeTruthy ( ) ;
93
-
94
- fixture . componentInstance . isHidden = true ;
95
- fixture . detectChanges ( ) ;
96
- expect ( progressElement . componentInstance . interdeterminateInterval ) . toBeFalsy ( ) ;
97
- } ) ;
98
-
99
- it ( 'should clean up the animation when a spinner is destroyed' , ( ) => {
100
- let fixture = TestBed . createComponent ( SpinnerWithNgIf ) ;
101
- fixture . detectChanges ( ) ;
102
-
103
- let progressElement = fixture . debugElement . query ( By . css ( 'md-spinner' ) ) ;
104
-
105
- expect ( progressElement . componentInstance . interdeterminateInterval ) . toBeTruthy ( ) ;
82
+ it ( 'should allow a custom stroke width' , ( ) => {
83
+ const fixture = TestBed . createComponent ( ProgressSpinnerCustomStrokeWidth ) ;
84
+ const circleElement = fixture . nativeElement . querySelector ( 'circle' ) ;
106
85
107
- fixture . componentInstance . isHidden = true ;
86
+ fixture . componentInstance . strokeWidth = 40 ;
108
87
fixture . detectChanges ( ) ;
109
88
110
- expect ( progressElement . componentInstance . interdeterminateInterval ) . toBeFalsy ( ) ;
89
+ expect ( parseInt ( circleElement . style . strokeWidth ) )
90
+ . toBe ( 40 , 'Expected the custom stroke width to be applied to the circle element.' ) ;
111
91
} ) ;
112
92
113
- it ( 'should set a default stroke width' , ( ) => {
114
- let fixture = TestBed . createComponent ( BasicProgressSpinner ) ;
115
- let pathElement = fixture . nativeElement . querySelector ( 'path ' ) ;
93
+ it ( 'should expand the host element if the stroke width is greater than the default ' , ( ) => {
94
+ const fixture = TestBed . createComponent ( ProgressSpinnerCustomStrokeWidth ) ;
95
+ const element = fixture . debugElement . nativeElement . querySelector ( '.mat-progress-spinner ' ) ;
116
96
97
+ fixture . componentInstance . strokeWidth = 40 ;
117
98
fixture . detectChanges ( ) ;
118
99
119
- expect ( parseInt ( pathElement . style . strokeWidth ) )
120
- . toBe ( PROGRESS_SPINNER_STROKE_WIDTH , 'Expected the default stroke-width to be applied. ') ;
100
+ expect ( element . style . width ) . toBe ( '130px' ) ;
101
+ expect ( element . style . height ) . toBe ( '130px ') ;
121
102
} ) ;
122
103
123
- it ( 'should allow a custom stroke width' , ( ) => {
124
- let fixture = TestBed . createComponent ( ProgressSpinnerCustomStrokeWidth ) ;
125
- let pathElement = fixture . nativeElement . querySelector ( 'path ' ) ;
104
+ it ( 'should not collapse the host element if the stroke width is less than the default ' , ( ) => {
105
+ const fixture = TestBed . createComponent ( ProgressSpinnerCustomStrokeWidth ) ;
106
+ const element = fixture . debugElement . nativeElement . querySelector ( '.mat-progress-spinner ' ) ;
126
107
127
- fixture . componentInstance . strokeWidth = 40 ;
108
+ fixture . componentInstance . strokeWidth = 5 ;
128
109
fixture . detectChanges ( ) ;
129
110
130
- expect ( parseInt ( pathElement . style . strokeWidth ) )
131
- . toBe ( 40 , 'Expected the custom stroke width to be applied to the path element. ') ;
111
+ expect ( element . style . width ) . toBe ( '100px' ) ;
112
+ expect ( element . style . height ) . toBe ( '100px ') ;
132
113
} ) ;
133
114
134
115
it ( 'should set the color class on the md-spinner' , ( ) => {
@@ -161,23 +142,6 @@ describe('MdProgressSpinner', () => {
161
142
expect ( progressElement . nativeElement . classList ) . not . toContain ( 'mat-primary' ) ;
162
143
} ) ;
163
144
164
- it ( 'should re-render the circle when switching from indeterminate to determinate mode' , ( ) => {
165
- let fixture = TestBed . createComponent ( ProgressSpinnerWithValueAndBoundMode ) ;
166
- let progressElement = fixture . debugElement . query ( By . css ( 'md-progress-spinner' ) ) . nativeElement ;
167
-
168
- fixture . componentInstance . mode = 'indeterminate' ;
169
- fixture . detectChanges ( ) ;
170
-
171
- let path = progressElement . querySelector ( 'path' ) ;
172
- let oldDimesions = path . getAttribute ( 'd' ) ;
173
-
174
- fixture . componentInstance . mode = 'determinate' ;
175
- fixture . detectChanges ( ) ;
176
-
177
- expect ( path . getAttribute ( 'd' ) ) . not
178
- . toBe ( oldDimesions , 'Expected circle dimensions to have changed.' ) ;
179
- } ) ;
180
-
181
145
it ( 'should remove the underlying SVG element from the tab order explicitly' , ( ) => {
182
146
const fixture = TestBed . createComponent ( BasicProgressSpinner ) ;
183
147
@@ -203,13 +167,6 @@ class IndeterminateProgressSpinner { }
203
167
@Component ( { template : '<md-progress-spinner value="50" [mode]="mode"></md-progress-spinner>' } )
204
168
class ProgressSpinnerWithValueAndBoundMode { mode = 'indeterminate' ; }
205
169
206
- @Component ( { template : `
207
- <md-progress-spinner mode="indeterminate" *ngIf="!isHidden"></md-progress-spinner>` } )
208
- class IndeterminateProgressSpinnerWithNgIf { isHidden = false ; }
209
-
210
- @Component ( { template : `<md-spinner *ngIf="!isHidden"></md-spinner>` } )
211
- class SpinnerWithNgIf { isHidden = false ; }
212
-
213
170
@Component ( { template : `<md-spinner [color]="color"></md-spinner>` } )
214
171
class SpinnerWithColor { color : string = 'primary' ; }
215
172
0 commit comments