fix: missing await

v1.18.x
Barış Soner Uşaklı 5 years ago
parent 28df9abadd
commit 97c086aba9

@ -236,7 +236,7 @@ Categories.getChildrenCids = async function (rootCid) {
}
keys = childrenCids.map(cid => 'cid:' + cid + ':children');
childrenCids.forEach(cid => allCids.push(parseInt(cid, 10)));
recursive(keys);
await recursive(keys);
}
const key = 'cid:' + rootCid + ':children';
const childrenCids = cache.get(key);

@ -910,4 +910,18 @@ describe('Categories', function () {
});
});
});
it('should return nested children categories', async function () {
const rootCategory = await Categories.create({ name: 'root' });
const child1 = await Categories.create({ name: 'child1', parentCid: rootCategory.cid });
const child2 = await Categories.create({ name: 'child2', parentCid: child1.cid });
const data = await Categories.getCategoryById({
uid: 1,
cid: rootCategory.cid,
start: 0,
stop: 19,
});
assert.strictEqual(child1.cid, data.children[0].cid);
assert.strictEqual(child2.cid, data.children[0].children[0].cid);
});
});

Loading…
Cancel
Save