From e7ce0cd7d6cd227749e1fd63dcf7abb9cba75d97 Mon Sep 17 00:00:00 2001 From: Peter Macdonald Date: Tue, 30 May 2023 09:51:14 +0200 Subject: [PATCH] writing tests Signed-off-by: Peter Macdonald --- .../OwnershipEntityRefPicker.test.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/scaffolder/src/components/fields/OwnershipEntityRefPicker/OwnershipEntityRefPicker.test.tsx b/plugins/scaffolder/src/components/fields/OwnershipEntityRefPicker/OwnershipEntityRefPicker.test.tsx index 1c1027634a..a290adbaee 100644 --- a/plugins/scaffolder/src/components/fields/OwnershipEntityRefPicker/OwnershipEntityRefPicker.test.tsx +++ b/plugins/scaffolder/src/components/fields/OwnershipEntityRefPicker/OwnershipEntityRefPicker.test.tsx @@ -91,12 +91,12 @@ describe('', () => { render(); - // Assuming the component calls `onChange` with the groups a user is a part of expect(onChange).toHaveBeenCalledWith(['group1', 'group2']); }); it('should not return groups a user is not part of', async () => { - catalogApi.getEntityByRef.mockResolvedValueOnce(entities[1]); + // Mock 'getEntityByRef' to return the entity that represents Bob + catalogApi.getEntityByRef.mockResolvedValueOnce(entities[0]); uiSchema = { 'ui:options': { catalogApi } }; props = { @@ -110,8 +110,8 @@ describe('', () => { render(); - // Assuming the component calls `onChange` with the groups a user is a part of - expect(onChange).not.toHaveBeenCalledWith(['group1', 'group2']); + // The onChange should not have been called with 'group3', since Bob is not part of 'group3' + expect(onChange).not.toHaveBeenCalledWith(['group3']); }); it('should render without imploding', () => {