我目前正在做模拟笑话的续集。目前,我在模拟javascript中的map函数时遇到问题。
要模拟的代码:
let hasDuplicate = false;
const modelAs = await this._modelA.findAll({
where: {
type: 'REG'
}
});
await Promise.all(modelAs.map(async modelA => {
const dbNumber = await TextUtil.reverseString(await CryptoUtil.decrypt(modelA.somethingA, modelA.somethingB));
if (dbNumber === sheet.getRow(i).getCell(8).value) {
hasDuplicate = true;
}
}));
我似乎无法嘲笑或覆盖这部分代码:
async modelA => {
const dbNumber = await TextUtil.reverseString(await CryptoUtil.decrypt(modelA.somethingA, modelA.somethingB));
if (dbNumber === sheet.getRow(i).getCell(8).value) {
hasDuplicate = true;
}
}
我当前的模拟脚本:
Wallet.findAll = () => Promise.resolve({
map: () => {
return [];
}
});