1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-11 10:10:25 +01:00

Fix web vault lock throwing an error (#10833)

This commit is contained in:
Jared Snider 2024-08-30 16:35:58 -04:00 committed by GitHub
parent d5cbc19187
commit 1b75261f68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 0 deletions

View File

@ -24,5 +24,16 @@ describe("CollectionUtils Service", () => {
expect(result[0].node.name).toBe("Parent"); expect(result[0].node.name).toBe("Parent");
expect(result[0].children[0].node.name).toBe("Child"); expect(result[0].children[0].node.name).toBe("Child");
}); });
it("should return an empty array if no collections are provided", () => {
// Arrange
const collections: CollectionView[] = [];
// Act
const result = getNestedCollectionTree(collections);
// Assert
expect(result).toEqual([]);
});
}); });
}); });

View File

@ -14,6 +14,10 @@ export function getNestedCollectionTree(collections: CollectionView[]): TreeNode
export function getNestedCollectionTree( export function getNestedCollectionTree(
collections: (CollectionView | CollectionAdminView)[], collections: (CollectionView | CollectionAdminView)[],
): TreeNode<CollectionView | CollectionAdminView>[] { ): TreeNode<CollectionView | CollectionAdminView>[] {
if (!collections) {
return [];
}
// Collections need to be cloned because ServiceUtils.nestedTraverse actively // Collections need to be cloned because ServiceUtils.nestedTraverse actively
// modifies the names of collections. // modifies the names of collections.
// These changes risk affecting collections store in StateService. // These changes risk affecting collections store in StateService.