import { Injector, runInInjectionContext } from '@angular/core';
import {
  describe,
  expect,
  it,
  vi
} from 'vitest';

import { PrivateCallControlsComponent } from './private-call-controls.component';

function createComponent(): PrivateCallControlsComponent {
  const injector = Injector.create({ providers: [PrivateCallControlsComponent] });

  return runInInjectionContext(injector, () => injector.get(PrivateCallControlsComponent));
}

describe('PrivateCallControlsComponent', () => {
  it('exposes deafened input and deafenToggled output', () => {
    const component = createComponent();

    expect(component.deafened).toBeDefined();
    expect(component.deafenToggled).toBeDefined();
  });

  it('emits deafenToggled when the output is triggered', () => {
    const component = createComponent();
    const handler = vi.fn();

    component.deafenToggled.subscribe(handler);
    component.deafenToggled.emit();

    expect(handler).toHaveBeenCalledTimes(1);
  });
});
