From 97c086aba9eecfdbf78fea408b9c93e62c603a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Tue, 12 May 2020 12:18:30 -0400 Subject: [PATCH] fix: missing await --- src/categories/index.js | 2 +- test/categories.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/categories/index.js b/src/categories/index.js index 03db4f68c5..371f71a579 100644 --- a/src/categories/index.js +++ b/src/categories/index.js @@ -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); diff --git a/test/categories.js b/test/categories.js index 82cf43acf1..242abd9294 100644 --- a/test/categories.js +++ b/test/categories.js @@ -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); + }); });