blob: 57f7b009cbd817e175c9930d38d6a98401e9cb05 [file] [log] [blame]
Ittay Stern6f900cc2018-08-29 17:01:32 +03001import {ComponentFixture, TestBed} from '@angular/core/testing';
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +03002import {HttpClientTestingModule} from '@angular/common/http/testing';
Ittay Stern6f900cc2018-08-29 17:01:32 +03003import {SpinnerComponent, SpinnerInfo} from './spinner.component';
4import {CUSTOM_ELEMENTS_SCHEMA} from "@angular/core";
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +03005
6describe('Spinner component', () => {
7 let component: SpinnerComponent;
8 let fixture: ComponentFixture<SpinnerComponent>;
9
Ittay Stern6f900cc2018-08-29 17:01:32 +030010 beforeAll(done => (async () => {
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030011 TestBed.configureTestingModule({
12 imports: [HttpClientTestingModule],
13 providers: [],
Ittay Stern6f900cc2018-08-29 17:01:32 +030014 declarations: [SpinnerComponent],
15 schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
16 });
17 await TestBed.compileComponents();
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030018
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030019 fixture = TestBed.createComponent(SpinnerComponent);
20 component = fixture.componentInstance;
21 fixture.detectChanges();
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030022
Ittay Stern6f900cc2018-08-29 17:01:32 +030023 })().then(done).catch(done.fail));
24
25
26
27 test('component should be defined', () => {
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030028 expect(component).toBeDefined();
29 });
30
Ittay Stern6f900cc2018-08-29 17:01:32 +030031 test('component constructor should subscribe of showSpinner event with true', ()=> {
32 let spinnerInfo : SpinnerInfo = new SpinnerInfo(true, 'someUrl', 'json');
33 SpinnerComponent.showSpinner.next(spinnerInfo);
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030034 expect(component.show).toBeTruthy();
35 });
36
Ittay Stern6f900cc2018-08-29 17:01:32 +030037 test('component constructor should subscribe of showSpinner event with true and then to be false', ()=> {
38 let spinnerInfo : SpinnerInfo = new SpinnerInfo(true, 'someUrl', 'json');
39 SpinnerComponent.showSpinner.next(spinnerInfo);
40 spinnerInfo = new SpinnerInfo(false, 'someUrl', 'json');
41 SpinnerComponent.showSpinner.next(spinnerInfo);
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030042 expect(component.show).toBeFalsy();
43 });
44
Ittay Stern6f900cc2018-08-29 17:01:32 +030045 test('component constructor should subscribe of showSpinner event with false', ()=> {
46 let spinnerInfo : SpinnerInfo = new SpinnerInfo(false, 'someUrl', 'json');
47 SpinnerComponent.showSpinner.next(spinnerInfo);
48 expect(component.show).toBeFalsy();
49 });
Sonsino, Ofir (os0695)ff76b5e2018-07-10 15:57:37 +030050});