mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: missing await
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user