Answer the question
In order to leave comments, you need to log in
How to test a function that generates a function?
Good afternoon, I'm studying testing, basic pure functions and so on do not raise questions, but I can't quite understand how to test such functions:
exports.isExistsValidator = (model, field) => {
return async (value) => {
const result = await model.findOne({ where: { [field]: value } });
if (!result) {
return Promise.reject(`${model.name} with ${field} = ${value} does not exists`);
}
}
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question