@@ -2,7 +2,6 @@ import {TestBed, async} from '@angular/core/testing';
22import { Component } from '@angular/core' ;
33import { By } from '@angular/platform-browser' ;
44import { MdProgressSpinnerModule } from './index' ;
5- import { PROGRESS_SPINNER_STROKE_WIDTH } from './progress-spinner' ;
65
76
87describe ( 'MdProgressSpinner' , ( ) => {
@@ -16,13 +15,9 @@ describe('MdProgressSpinner', () => {
1615 ProgressSpinnerWithValueAndBoundMode ,
1716 ProgressSpinnerWithColor ,
1817 ProgressSpinnerCustomStrokeWidth ,
19- IndeterminateProgressSpinnerWithNgIf ,
20- SpinnerWithNgIf ,
21- SpinnerWithColor
18+ SpinnerWithColor ,
2219 ] ,
23- } ) ;
24-
25- TestBed . compileComponents ( ) ;
20+ } ) . compileComponents ( ) ;
2621 } ) ) ;
2722
2823 it ( 'should apply a mode of "determinate" if no mode is provided.' , ( ) => {
@@ -84,51 +79,37 @@ describe('MdProgressSpinner', () => {
8479 expect ( progressComponent . value ) . toBe ( 0 ) ;
8580 } ) ;
8681
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' ) ;
10685
107- fixture . componentInstance . isHidden = true ;
86+ fixture . componentInstance . strokeWidth = 40 ;
10887 fixture . detectChanges ( ) ;
10988
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.' ) ;
11191 } ) ;
11292
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 ' ) ;
11696
97+ fixture . componentInstance . strokeWidth = 40 ;
11798 fixture . detectChanges ( ) ;
11899
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 ') ;
121102 } ) ;
122103
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 ' ) ;
126107
127- fixture . componentInstance . strokeWidth = 40 ;
108+ fixture . componentInstance . strokeWidth = 5 ;
128109 fixture . detectChanges ( ) ;
129110
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 ') ;
132113 } ) ;
133114
134115 it ( 'should set the color class on the md-spinner' , ( ) => {
@@ -161,23 +142,6 @@ describe('MdProgressSpinner', () => {
161142 expect ( progressElement . nativeElement . classList ) . not . toContain ( 'mat-primary' ) ;
162143 } ) ;
163144
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-
181145 it ( 'should remove the underlying SVG element from the tab order explicitly' , ( ) => {
182146 const fixture = TestBed . createComponent ( BasicProgressSpinner ) ;
183147
@@ -203,13 +167,6 @@ class IndeterminateProgressSpinner { }
203167@Component ( { template : '<md-progress-spinner value="50" [mode]="mode"></md-progress-spinner>' } )
204168class ProgressSpinnerWithValueAndBoundMode { mode = 'indeterminate' ; }
205169
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-
213170@Component ( { template : `<md-spinner [color]="color"></md-spinner>` } )
214171class SpinnerWithColor { color : string = 'primary' ; }
215172
0 commit comments