
import {of as observableOf,  Observable } from 'rxjs';
import { TelemetryStartDirective } from './telemetry-start.directive';
import { IStartEventInput } from '../../interfaces';
import { TelemetryService, TELEMETRY_PROVIDER } from '../../services';
import {TestBed, ComponentFixture} from '@angular/core/testing';
import {eventData} from './telemetry-start.directive.spec.data';
describe('TelemetryStartDirective', () => {
  beforeEach(() => {
    TestBed.configureTestingModule({
      declarations: [TelemetryStartDirective],
      providers: [TelemetryService, { provide: TELEMETRY_PROVIDER, useValue: EkTelemetry}]
    });
  });
  it('should take input and  generate the telemetry start event', () => {
    const telemetryService = TestBed.get(TelemetryService);
    const directive = new TelemetryStartDirective(telemetryService);
    spyOn(telemetryService, 'start').and.callFake(() => observableOf(eventData.inputData));
    directive.appTelemetryStart = eventData.inputData;
    directive.ngOnChanges();
    expect(directive.appTelemetryStart).toBeDefined();
    expect(directive.appTelemetryStart).toBe(eventData.inputData);
    expect(telemetryService.start).toHaveBeenCalled();
  });
});

{'avg_line_length': 46.19230769230769, 'max_line_length': 91, 'alphanum_fraction': 0.7352206494587843, 'licenses': ['MIT'], 'repository_name': 'Abhishekkp-zool/SunbirdEd-portal', 'path': 'src/app/client/src/app/modules/telemetry/directives/telemetry-start/telemetry-start.directive.spec.ts', 'size': 1201, 'lang': 'TypeScript'}