import {NgxMaterialTimepickerEventService} from './ngx-material-timepicker-event.service'; import {TestBed} from '@angular/core/testing'; describe('NgxMaterialTimepickerService', () => { let eventService: NgxMaterialTimepickerEventService; beforeEach(() => { TestBed.configureTestingModule({ providers: [NgxMaterialTimepickerEventService] }); eventService = TestBed.get(NgxMaterialTimepickerEventService); }); it('should dispatch click event', () => { eventService.backdropClick.subscribe(event => expect(event.type).toBe('click')); eventService.dispatchEvent({type: 'click'}); }); it('should dispatch keydown event', () => { eventService.keydownEvent.subscribe(event => expect(event.type).toBe('keydown')); eventService.dispatchEvent({type: 'keydown'}); }); it('should throw error if wrong event type', () => { expect(() => eventService.dispatchEvent({type: 'mouseout'})).toThrowError('no such event type'); }); });