fix: Guard empty documentStructure

This commit is contained in:
Tom Moor
2021-05-22 21:12:47 -07:00
parent 7dc11e5b86
commit 6c011eb9b5
2 changed files with 13 additions and 1 deletions

View File

@ -442,7 +442,10 @@ Collection.prototype.getDocumentParents = function (
});
};
if (this.documentStructure) {
loopChildren(this.documentStructure);
}
return result;
};

View File

@ -54,6 +54,15 @@ describe("getDocumentParents", () => {
const result = collection.getDocumentParents(parent.id);
expect(result.length).toBe(0);
});
test("should not error if documentStructure is empty", async () => {
const parent = await buildDocument();
await buildDocument();
const collection = await buildCollection();
const result = collection.getDocumentParents(parent.id);
expect(result).toBe(undefined);
});
});
describe("getDocumentTree", () => {