import { IUiInputOptions, UiInputOptions } from './ui-input-options';
import { UiOption } from './ui-option';

describe('UiInputOptions', () => {
  const testData: IUiInputOptions = {
    max: 2,
    values: [
      { label: 'abgeholt', value: '256' },
      { label: 'angefragt', value: '524288' },
      { label: 'ans Lager (nicht abgeholt)', value: '262144' },
      { label: 'bestellt', value: '16', selected: true },
    ],
  };

  let inputOptions: UiInputOptions;

  beforeEach(() => {
    spyOn(UiOption, 'create');
    inputOptions = UiInputOptions.create(testData);
  });

  describe('static create(inputOptions: IUiInputOptions)', () => {
    it('should return an instance of IUiInputOptions', () => {
      expect(inputOptions instanceof UiInputOptions).toBe(true);
      expect(inputOptions.max).toBe(testData.max);
      testData.values.forEach((value) => expect(UiOption.create).toHaveBeenCalledWith(value, inputOptions));
    });
  });
});
