Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 1 | import {ComponentFixture, TestBed} from '@angular/core/testing'; |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 2 | import {HttpClientTestingModule} from '@angular/common/http/testing'; |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 3 | import {SpinnerComponent, SpinnerInfo} from './spinner.component'; |
| 4 | import {CUSTOM_ELEMENTS_SCHEMA} from "@angular/core"; |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 5 | |
| 6 | describe('Spinner component', () => { |
| 7 | let component: SpinnerComponent; |
| 8 | let fixture: ComponentFixture<SpinnerComponent>; |
| 9 | |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 10 | beforeAll(done => (async () => { |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 11 | TestBed.configureTestingModule({ |
| 12 | imports: [HttpClientTestingModule], |
| 13 | providers: [], |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 14 | declarations: [SpinnerComponent], |
| 15 | schemas: [ CUSTOM_ELEMENTS_SCHEMA ] |
| 16 | }); |
| 17 | await TestBed.compileComponents(); |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 18 | |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 19 | fixture = TestBed.createComponent(SpinnerComponent); |
| 20 | component = fixture.componentInstance; |
| 21 | fixture.detectChanges(); |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 22 | |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 23 | })().then(done).catch(done.fail)); |
| 24 | |
| 25 | |
| 26 | |
| 27 | test('component should be defined', () => { |
Sonsino, Ofir (os0695) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 28 | expect(component).toBeDefined(); |
| 29 | }); |
| 30 | |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 31 | 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) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 34 | expect(component.show).toBeTruthy(); |
| 35 | }); |
| 36 | |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 37 | 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) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 42 | expect(component.show).toBeFalsy(); |
| 43 | }); |
| 44 | |
Ittay Stern | 6f900cc | 2018-08-29 17:01:32 +0300 | [diff] [blame] | 45 | 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) | ff76b5e | 2018-07-10 15:57:37 +0300 | [diff] [blame] | 50 | }); |