I am working on a simple method where i need to add test case using enzyme OR jest.
const export inputValidation = (phnum,pincode,setvalue) => {
//remove zipcode message
//remove phnum message
if (phnum?.length < 10 && setvalue) {
//phnum must be 10 digit(error message)
}
if (pincode?.length < 7 && setvalue) {
//zipcode must be 7 digit (error message)
}
//just return true or false
}
I never wrote function test case , I need some help on this.
test case i tried
describe(validation test case () =>{
it(CHECK IF PHONE NUMBER IS 10 DIGIT ELSE SET SOME MESSAGE ,()=>{
expect(inputValidation (12345678,1235667,true).ToEqual('')
})
})
else can we mock this function and check each parameter??
how do we check each input field is having limits??
i can check what the error message is displaying , i want to know how to frame it