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

149
Visualizações
What value to give void properties

I have this interface:

interface Props {
    close: () => void;
    disableButton: () => void;
    showPrompt: boolean;
    pol: string;
}

I'm trying to use it in a test. My problem is that I don't know what I should do with close and disableButton. They are just passed to that class so the state can be updated. What value do I give the variables for use in my shallow?

describe('<Reissue />', () => {
    it('calls reissue service', () => {
        const close = ???;
        const disableButton = ???;
        const showPrompt = true;
        const pol = '123456';

        const wrapper = shallow(<Reissue close={} disableButton={} showPrompt={showPrompt} pol={pol}/>);
    });    
});
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

The void keyword in this context is used to indicate that the function returns no value, hence you can just use an empty closure () => {}.

If you are using jest, you can also use jest.fn(), which will behave the same but has the benefit of capturing information that will help you during your tests (e.g. how many times the function have been called)

https://jestjs.io/docs/mock-functions

about 4 years ago · Juan Pablo Isaza Relatório

0

close and disableButton are functions so you should pass functions to them, even if empty empty ones -

const wrapper = shallow(<Reissue close={()=>()} disableButton={()=>()} showPrompt={showPrompt} pol={pol}/>);
about 4 years ago · Juan Pablo Isaza Relatório
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