import 'reflect-metadata'; import { NumberPickerComponent, } from './number-picker.component'; const initNumberPickerComponent = () => { return new NumberPickerComponent(); }; describe('canDecrease', () => { test('Returns true if value is greater than minValue', () => { const numberPickerComponent = initNumberPickerComponent(); numberPickerComponent.value = 1; numberPickerComponent.minValue = 0; const result = numberPickerComponent.canDecrease(); expect(result).toBe(true); }); test('Returns false if value is equal to minValue', () => { const numberPickerComponent = initNumberPickerComponent(); numberPickerComponent.value = 0; numberPickerComponent.minValue = 0; const result = numberPickerComponent.canDecrease(); expect(result).toBe(false); }); }); describe('canIncrease', () => { test('Returns true if value is less than maxValue', () => { const numberPickerComponent = initNumberPickerComponent(); numberPickerComponent.value = 0; numberPickerComponent.maxValue = 1; const result = numberPickerComponent.canIncrease(); expect(result).toBe(true); }); test('Returns false if value is equal to maxValue', () => { const numberPickerComponent = initNumberPickerComponent(); numberPickerComponent.value = 0; numberPickerComponent.maxValue = 0; const result = numberPickerComponent.canIncrease(); expect(result).toBe(false); }); }); describe('decreaseClicked', () => { test('Emits an even to onDecreaseClicked', () => { const numberPickerComponent = initNumberPickerComponent(); numberPickerComponent.onDecreaseClicked.emit = jest.fn(); numberPickerComponent.decreaseClicked(); expect(numberPickerComponent.onDecreaseClicked.emit) .toHaveBeenCalled(); }); }); describe('increaseClicked', () => { test('Emits an even to onIncreaseClicked', () => { const numberPickerComponent = initNumberPickerComponent(); numberPickerComponent.onIncreaseClicked.emit = jest.fn(); numberPickerComponent.increaseClicked(); expect(numberPickerComponent.onIncreaseClicked.emit) .toHaveBeenCalled(); }); });