I have a function, code is written below. I am using lab as code coverage tool.
getClients = async (partnerId) => {
try {
const results = await PartnersClients.findAll({
attributes: ['clientId'],
where: {
partnerId,
},
include: [{
model: Models.Entries,
attributes: ['section'],
}],
});
if (!results.length) return false;
return results.map(result => ({
clientId: result.dataValues.clientId,
section: result.dataValues.Entries.length ? result.dataValues.Entries[0].dataValues.section : '',
}));
} catch (error) {
return false;
}
};
I have written tests for it but this line section: result.dataValues.Entries.length ? result.dataValues.Entries[0].dataValues.section : ''
shown as not covered. Also on most of the code lines where I have used loops or iterator methods are showing as not covered. I am wondering how should I cover it. als