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

217
Visualizações
Test is failing as one of the array is modified in the main component

I'm trying to empty an array named Variables which is located inside alertdetails object in React as it is a fix for one of the bugs but by doing so the existing Test cases are failing in this case how do I re-write the test case so that it doesn't fail?

it('should open send template drawer when "send now" button is clicked and initiator form feature is turned on and there are variables', () => {
        wrapper.setProps({
            alertDetails: {
                ...props.alertDetails,
                variables: [{ id: 1, group: 'placeholder' }]
            }
        });
        refreshComponent('actions');

        const sendButton = actions.find(CreateAlertsSendButton);

        sendButton.prop('onSendNow')();

        const drawer = wrapper.find(SendTemplate);

        expect(drawer.prop('isOpen')).toBeTruthy();
    });

    it('should not open send template drawer when "send now" button is clicked and initiator form feature is turned off', () => {
        const sendButton = actions.find(CreateAlertsSendButton);

        sendButton.prop('onSendNow')();

        const drawer = wrapper.find(SendTemplate);

        expect(drawer.exists()).toBeFalsy();
    });
     it('should call sendAlert when send template drawer executes callback', () => {
        wrapper.setProps({
            alertDetails: {
                ...props.alertDetails,
                variables: [{ id: 1, group: 'placeholder' }]
            }
        });
        refreshComponent('actions');

        const sendButton = actions.find(CreateAlertsSendButton);

        sendButton.prop('onSendNow')();

        wrapper
            .find('SendTemplate')
            .props()
            .onSendNow({ placeholders: 'placeholders' });

        expect(props.setVariableValues).toHaveBeenCalledWith('placeholders');
        expect(props.sendAlert).toHaveBeenCalledWith(AlertSendType.SEND_ONE_STEP, { redirectUrl: '' });
    });

Sorry for the extended code, the above three cases fail if I empty the Variables array

Currently, this test case checks whether we have a placeholder in alertDetails.Variables array but I need to implement it in a way that it should check from alertDetails.alertMessage so that emptying variables array doesn't affect these cases. I'd appreciate any help thanks!

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