77 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
88 */
99
10- import { async , ComponentFixture , TestBed } from '@angular/core/testing' ;
10+ import { async , ComponentFixture , fakeAsync , TestBed , tick } from '@angular/core/testing' ;
1111import { SpinnerComponent } from './spinner.component' ;
1212import { HttpInterceptorServiceFactoryProvider } from '../http-interceptor.service' ;
1313import { HttpModule } from '@angular/http' ;
14+ import { By } from '@angular/platform-browser' ;
15+ import { Spinkit } from '../spinkits' ;
1416
1517describe ( 'SpinnerComponent' , ( ) => {
1618 let component : SpinnerComponent ;
@@ -34,4 +36,55 @@ describe('SpinnerComponent', () => {
3436 it ( 'should create the spinner component' , ( ) => {
3537 expect ( component ) . toBeTruthy ( ) ;
3638 } ) ;
39+
40+ it ( 'should create the spinner component with default values' , fakeAsync ( ( ) => {
41+ component . isSpinnerVisible = true ;
42+ fixture . detectChanges ( ) ;
43+ tick ( ) ;
44+
45+ const element = fixture
46+ . debugElement
47+ . query ( By . css ( '.sk-cube-grid' ) )
48+ . nativeElement ;
49+
50+ expect ( element . className ) . toBe ( 'sk-cube-grid colored' ) ;
51+ } ) ) ;
52+
53+ it ( 'should not set the colored class if background-color is defined' , fakeAsync ( ( ) => {
54+ component . isSpinnerVisible = true ;
55+ component . backgroundColor = '#ff0000' ;
56+
57+ fixture . detectChanges ( ) ;
58+ tick ( ) ;
59+
60+ const element = fixture
61+ . debugElement
62+ . query ( By . css ( '.sk-cube-grid' ) )
63+ . nativeElement ;
64+
65+ expect ( element . className ) . toBe ( 'sk-cube-grid' ) ;
66+ } ) ) ;
67+
68+ it ( 'should not display anything by default' , fakeAsync ( ( ) => {
69+ const element = fixture
70+ . debugElement
71+ . query ( By . css ( '#http-loader' ) ) ;
72+
73+ expect ( element ) . toBeNull ( ) ;
74+ } ) ) ;
75+
76+ it ( 'should be able to specify another known spinner' , fakeAsync ( ( ) => {
77+ component . isSpinnerVisible = true ;
78+ component . spinner = Spinkit . skRotatingPlane ;
79+
80+ fixture . detectChanges ( ) ;
81+ tick ( ) ;
82+
83+ const element = fixture
84+ . debugElement
85+ . query ( By . css ( '.sk-rotating-plane' ) )
86+ . nativeElement ;
87+
88+ expect ( element . className ) . toBe ( 'sk-rotating-plane colored-parent' ) ;
89+ } ) ) ;
3790} ) ;
0 commit comments