|
| 1 | +/* |
| 2 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 3 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
| 4 | + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
| 5 | + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
| 6 | + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 7 | + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 8 | + */ |
| 9 | + |
| 10 | +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
| 11 | +import { SpinnerComponent } from '../../../src/components/spinner/spinner.component'; |
| 12 | +import { By } from '@angular/platform-browser'; |
| 13 | +import { SPINKIT_COMPONENTS } from '../../../src/spinkits'; |
| 14 | +import { HttpClientTestingModule } from '@angular/common/http/testing'; |
| 15 | +import { NgHttpLoaderServicesModule } from '../../../src/services/ng-http-loader-services.module'; |
| 16 | +import 'rxjs/add/observable/forkJoin'; |
| 17 | +import { SkThreeBounceComponent } from '../../../src/components/sk-three-bounce/sk-three-bounce.component'; |
| 18 | +import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; |
| 19 | + |
| 20 | +describe('SpinnerNgOutletComponent', () => { |
| 21 | + let component: SpinnerComponent; |
| 22 | + let fixture: ComponentFixture<SpinnerComponent>; |
| 23 | + |
| 24 | + beforeEach(async(() => { |
| 25 | + |
| 26 | + TestBed.configureTestingModule({ |
| 27 | + declarations: [SpinnerComponent, SPINKIT_COMPONENTS], |
| 28 | + imports: [NgHttpLoaderServicesModule, HttpClientTestingModule] |
| 29 | + }) |
| 30 | + .overrideModule(BrowserDynamicTestingModule, { |
| 31 | + set: { |
| 32 | + entryComponents: [SkThreeBounceComponent] |
| 33 | + } |
| 34 | + }) |
| 35 | + .compileComponents(); |
| 36 | + |
| 37 | + })); |
| 38 | + |
| 39 | + beforeEach(() => { |
| 40 | + fixture = TestBed.createComponent(SpinnerComponent); |
| 41 | + component = fixture.componentInstance; |
| 42 | + }); |
| 43 | + |
| 44 | + it('should be possible to specify an entryComponent', () => { |
| 45 | + component.isSpinnerVisible = true; |
| 46 | + component.entryComponent = SkThreeBounceComponent; |
| 47 | + fixture.detectChanges(); |
| 48 | + |
| 49 | + const element = fixture |
| 50 | + .debugElement |
| 51 | + .query(By.css('.sk-bounce1')) |
| 52 | + .nativeElement; |
| 53 | + |
| 54 | + expect(element.className).toBe('sk-child sk-bounce1'); |
| 55 | + }); |
| 56 | + |
| 57 | + it('should force [spinner] to null if entryComponent is defined', () => { |
| 58 | + component.isSpinnerVisible = true; |
| 59 | + component.spinner = 'whatever'; |
| 60 | + component.entryComponent = SkThreeBounceComponent; |
| 61 | + fixture.detectChanges(); |
| 62 | + |
| 63 | + expect(component.spinner).toBeNull(); |
| 64 | + }); |
| 65 | +}); |
0 commit comments