Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

145
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!