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

import {ComponentFixture, TestBed} from '@angular/core/testing';
import {BciNumberPickerComponent} from './bci-number-picker.component';

const SELECTED_MAX_VALUE = 59;

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

  beforeEach(async () => {
    await TestBed.configureTestingModule({
      imports: [ BciNumberPickerComponent ]
    })
      .compileComponents();

    fixture = TestBed.createComponent(BciNumberPickerComponent);
    component = fixture.componentInstance;
    component.maxValue = SELECTED_MAX_VALUE;
    fixture.detectChanges();
  });

  it('should create', (): void => {
    expect(component).toBeTruthy();
  });

  it('value should stay in selected range', (): void => {
    component.value = SELECTED_MAX_VALUE + 1;
    component.checkAndFitToRange();
    expect(component.value).toBe(SELECTED_MAX_VALUE);

    component.value = -4;
    component.checkAndFitToRange();
    expect(component.value).toBe(component.minValue);
  });

  it('should increase in range', (): void => {
    component.value = SELECTED_MAX_VALUE;
    component.increase();
    expect(component.value).toBe(component.minValue);
  });

  it('should decrease in range', (): void => {
    component.value = component.minValue;
    component.decrease();
    expect(component.value).toBe(SELECTED_MAX_VALUE);
  });
});
