From e821a3db3d132696a8ea27f9bd6eb3bb33f4db6c Mon Sep 17 00:00:00 2001 From: Luka Siric Date: Tue, 6 Sep 2022 13:49:02 +0200 Subject: [PATCH] added unit test for userSelect option Signed-off-by: Luka Siric --- .../src/microsoftGraph/read.test.ts | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/plugins/catalog-backend-module-msgraph/src/microsoftGraph/read.test.ts b/plugins/catalog-backend-module-msgraph/src/microsoftGraph/read.test.ts index 3f43807809..7fe98cf1cf 100644 --- a/plugins/catalog-backend-module-msgraph/src/microsoftGraph/read.test.ts +++ b/plugins/catalog-backend-module-msgraph/src/microsoftGraph/read.test.ts @@ -1002,6 +1002,12 @@ describe('read microsoft graph', () => { }; } + async function* getExampleUsersEmail() { + yield { + mail: 'user.name@example.com', + }; + } + async function getExampleUserProfile(userId: string) { return { id: userId, @@ -1109,6 +1115,37 @@ describe('read microsoft graph', () => { ); }); + it('should read users with userSelect', async () => { + client.getOrganization.mockResolvedValue({ + id: 'tenantid', + displayName: 'Organization Name', + }); + + client.getUsers.mockImplementation(getExampleUsersEmail); + client.getUserPhotoWithSizeLimit.mockResolvedValue( + 'data:image/jpeg;base64,...', + ); + + client.getGroups.mockImplementation(getExampleGroups); + client.getGroupMembers.mockImplementation(getExampleGroupMembers); + client.getGroupPhotoWithSizeLimit.mockResolvedValue( + 'data:image/jpeg;base64,...', + ); + + await readMicrosoftGraphOrg(client, 'tenantid', { + logger: getVoidLogger(), + userSelect: ['mail'], + }); + + expect(client.getUsers).toHaveBeenCalledTimes(1); + expect(client.getUsers).toHaveBeenCalledWith( + { + select: ['mail'], + }, + undefined, + ); + }); + it('should read users using userExpand and userGroupMemberFilter', async () => { client.getOrganization.mockResolvedValue({ id: 'tenantid',