import { getFocusableTime } from './getFocusableTime';

describe('getFocusableTime', () => {
  const isActive = (value: number) => value === 2;
  const isNow = (value: number) => value === 3;
  const isDisabled = (value: number) => value === 4;
  const values = [1, 2, 3, 4, 5];

  it('returns first selected value', () => {
    expect(getFocusableTime({ isActive, isNow, isDisabled, timeSpan: values })).toBe(2);
  });

  it('returns first now value if nothing is selected', () => {
    expect(getFocusableTime({ isActive: () => false, isNow, isDisabled, timeSpan: values })).toBe(
      3,
    );
  });

  it('returns first non disabled value when nothing is selected or now', () => {
    expect(
      getFocusableTime({
        isActive: () => false,
        isNow: () => false,
        isDisabled,
        timeSpan: values,
      }),
    ).toBe(1);
  });

  it('returns null if no selected, now, or non-disabled', () => {
    expect(
      getFocusableTime({
        isActive: () => false,
        isNow: () => false,
        isDisabled: () => true,
        timeSpan: values,
      }),
    ).toBeUndefined();
  });
});
