Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

116
Visualizações
How can I mock the event argument in karma chai sinon mocha

How can I mock the event argument in karma chai sinon mocha ?

it('should have onmute event on tracks', async () => {
        if (fakeAudioTracks[0].onmute !== null) {
          console.log('before fakeAudioTracks[0] ', fakeAudioTracks[0]);

          eventCallbackSpy = Sinon.spy();
          subscriptions.events['track:mute'].set(subscription.listener.id, eventCallbackSpy);

          fakeAudioTracks[0].enabled = true;
          fakeAudioTracks[0].onmute(new Event('mute'));

          Sinon.assert.called(eventCallbackSpy);
          // expect(eventCallbackSpy.getCall(0).args[0].action).to.be.equal('muted');
          console.log('After fakeAudioTracks[0] ', fakeAudioTracks[0]);
          expect(eventCallbackSpy.getCall(0).args[0].action).to.be.equal('muted');
        }
      });

This is my test case, I want to pass an argument fakeAudioTracks[0] to fakeAudioTracks[0].onmute(new Event('mute')); this.

My onmute -

export function onmute(event: Event) : void {
  console.log('event ', event.target);
  const onmuteListeners: eventListeners = subscriptions.events['track:mute'];

  for (const entry of onmuteListeners) {
    const listener = entry[1];

    if (listener) {
      listener({
        action: 'muted' || 'unmuted', // need to check the event.target and return this.
        // action: event.target.enabled === 'true' ? 'muted' : 'unmuted',
        track: <MediaStreamTrack> event.target,
      });
    }
  }
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda