import {OptionList} from './option-list'; import {Option} from './option'; import {IOption} from './option.interface'; const numbers = [0, 1, 2, 3, 4]; describe('An OptionList\'s constructor', () => { let options: Array; let invalidOptions: Array; beforeEach(() => { let options: Array = numbers.map((i) => { return { label: `Option ${i}`, value: `${i}` }; }); let invalidOptions: Array = [{ label: 'Option 1', value: '1' }, { view: 'Invalid option label', value: '2' }]; }); it('creates empty list if undefined is provided as parameter', () => { let optionList: OptionList = new OptionList(undefined); expect(optionList.options.length).toBe(0); expect(optionList.hasShown).toBe(false); expect(optionList.highlightedOption).toBe(null); }); it('creates empty list if null is provided as parameter', () => { let optionList: OptionList = new OptionList(null); expect(optionList.options.length).toBe(0); expect(optionList.hasShown).toBe(false); expect(optionList.highlightedOption).toBe(null); }); }); describe('An OptionList\'s getOptionsByValue function', () => { let optionList: OptionList; beforeEach(() => { let options: Array = numbers.map((i) => { return { label: `Option ${i}`, value: `${i}` }; }); optionList = new OptionList(options); }); it('returns empty list if list of options is empty', () => { optionList = new OptionList([]); let result: Array