aboutsummaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/shared/components/spinner/spinner.component.spec.ts
blob: 57f7b009cbd817e175c9930d38d6a98401e9cb05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {HttpClientTestingModule} from '@angular/common/http/testing';
import {SpinnerComponent, SpinnerInfo} from './spinner.component';
import {CUSTOM_ELEMENTS_SCHEMA} from "@angular/core";

describe('Spinner component', () => {
  let component: SpinnerComponent;
  let fixture: ComponentFixture<SpinnerComponent>;

  beforeAll(done => (async () => {
    TestBed.configureTestingModule({
      imports: [HttpClientTestingModule],
      providers: [],
      declarations: [SpinnerComponent],
      schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
    });
    await TestBed.compileComponents();

    fixture = TestBed.createComponent(SpinnerComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();

  })().then(done).catch(done.fail));



  test('component should be defined', () => {
    expect(component).toBeDefined();
  });

  test('component constructor should subscribe of showSpinner event with true', ()=> {
    let spinnerInfo : SpinnerInfo = new SpinnerInfo(true, 'someUrl', 'json');
    SpinnerComponent.showSpinner.next(spinnerInfo);
    expect(component.show).toBeTruthy();
  });

  test('component constructor should subscribe of showSpinner event with true and then to be false', ()=> {
    let spinnerInfo : SpinnerInfo = new SpinnerInfo(true, 'someUrl', 'json');
    SpinnerComponent.showSpinner.next(spinnerInfo);
    spinnerInfo  = new SpinnerInfo(false, 'someUrl', 'json');
    SpinnerComponent.showSpinner.next(spinnerInfo);
    expect(component.show).toBeFalsy();
  });

  test('component constructor should subscribe of showSpinner event with false', ()=> {
    let spinnerInfo : SpinnerInfo = new SpinnerInfo(false, 'someUrl', 'json');
    SpinnerComponent.showSpinner.next(spinnerInfo);
    expect(component.show).toBeFalsy();
  });
});