/*
 * Copyright (C) 2018 Robert Bosch GmbH Copyright (C) 2018 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved.
 */

import { NgModule } from '@angular/core';
import { TestBed } from '@angular/core/testing';
import { OverlayModule } from '@angular/cdk/overlay';

import { BciLoaderService } from './bci-loader.service';
import { BciLoaderComponent } from './bci-loader.component';

@NgModule({
  imports: [OverlayModule],
  declarations: [BciLoaderComponent],
})
class BciLoaderTestModule {}

describe('BciLoaderService', () => {
  let service: BciLoaderService;

  beforeEach(() => {
    TestBed.configureTestingModule({
      imports: [BciLoaderTestModule],
    });
    service = TestBed.inject(BciLoaderService);
  });

  it('should be created', () => {
    expect(service).toBeTruthy();
    expect(document.querySelectorAll('.loader-background-container').length).toBe(0);
  });

  it('should show and hide loader by calling service', () => {
    expect(document.querySelectorAll('.loader-background-container').length).toBe(0);

    const loaderQueueElement = service.showProgressBar();
    expect(document.querySelectorAll('.loader-background-container').length).toBe(1);

    service.hideProgressBar(loaderQueueElement);
    expect(document.querySelectorAll('.loader-background-container').length).toBe(0);
  });
});
